Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

接続相手のポートとの通信でCOMM_FAILURE_WaitingForReply例外が発生した場合に接続をリトライする #283

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions OpenRTM_aist/InPortCorbaCdrConsumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# All rights reserved.
#


import omniORB
from omniORB import any
from omniORB import CORBA
import OpenRTM_aist
Expand Down Expand Up @@ -155,8 +155,18 @@ def put(self, data):

try:
inportcdr = self._ptr()

if inportcdr:
return self.convertReturnCode(inportcdr.put(data))
try:
return self.convertReturnCode(inportcdr.put(data))
except CORBA.COMM_FAILURE as ex:
if ex.minor == omniORB.COMM_FAILURE_WaitingForReply:
self._rtcout.RTC_DEBUG("Retry put message")
return self.convertReturnCode(inportcdr.put(data))
else:
raise
except BaseException:
raise
return self.CONNECTION_LOST
except BaseException:
self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
Expand Down
12 changes: 11 additions & 1 deletion OpenRTM_aist/InPortDSConsumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# All rights reserved.


import omniORB
from omniORB import any
from omniORB import CORBA
import OpenRTM_aist
Expand Down Expand Up @@ -154,7 +155,16 @@ def put(self, data):
try:
dataservice = self._ptr()
if dataservice:
return self.convertReturnCode(dataservice.push(data))
try:
return self.convertReturnCode(dataservice.push(data))
except CORBA.COMM_FAILURE as ex:
if ex.minor == omniORB.COMM_FAILURE_WaitingForReply:
self._rtcout.RTC_DEBUG("Retry push message")
return self.convertReturnCode(dataservice.push(data))
else:
raise
except BaseException:
raise
return self.CONNECTION_LOST
except BaseException:
self._rtcout.RTC_ERROR(OpenRTM_aist.Logger.print_exception())
Expand Down
27 changes: 20 additions & 7 deletions OpenRTM_aist/InPortSHMConsumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
# @author Nobuhiko Miyamoto
#


import omniORB
from omniORB import CORBA
import OpenRTM_aist
import OpenRTM__POA

Expand Down Expand Up @@ -184,12 +185,24 @@ def put(self, data):
if portshmem:

guard = OpenRTM_aist.ScopedLock(self._mutex)

self._shmem.setEndian(self._endian)
self._shmem.create_memory(self._memory_size, self._shm_address)
self._shmem.write(data)

ret = portshmem.put()
try:
self._shmem.setEndian(self._endian)
self._shmem.create_memory(
self._memory_size, self._shm_address)
self._shmem.write(data)
ret = portshmem.put()
except CORBA.COMM_FAILURE as ex:
if ex.minor == omniORB.COMM_FAILURE_WaitingForReply:
self._rtcout.RTC_DEBUG("Retry put message")
self._shmem.setEndian(self._endian)
self._shmem.create_memory(
self._memory_size, self._shm_address)
self._shmem.write(data)
ret = portshmem.put()
else:
raise
except BaseException:
raise
del guard
return self.convertReturnCode(ret)
return self.CONNECTION_LOST
Expand Down
13 changes: 12 additions & 1 deletion OpenRTM_aist/OutPortCorbaCdrConsumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
#


import omniORB
from omniORB import any
from omniORB import CORBA
import OpenRTM_aist
import OpenRTM

Expand Down Expand Up @@ -201,7 +203,16 @@ def get(self):
try:
data = None
outportcdr = self._ptr()
ret, cdr_data = outportcdr.get()
try:
ret, cdr_data = outportcdr.get()
except CORBA.COMM_FAILURE as ex:
if ex.minor == omniORB.COMM_FAILURE_WaitingForReply:
self._rtcout.RTC_DEBUG("Retry get message")
ret, cdr_data = outportcdr.get()
else:
raise
except BaseException:
raise

if ret == OpenRTM.PORT_OK:
self._rtcout.RTC_DEBUG("get() successful")
Expand Down
13 changes: 12 additions & 1 deletion OpenRTM_aist/OutPortDSConsumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
# All rights reserved.


import omniORB
from omniORB import any
from omniORB import CORBA
import OpenRTM_aist
import RTC

Expand Down Expand Up @@ -199,7 +201,16 @@ def get(self):
try:
data = None
dataservice = self._ptr()
ret, cdr_data = dataservice.pull()
try:
ret, cdr_data = dataservice.pull()
except CORBA.COMM_FAILURE as ex:
if ex.minor == omniORB.COMM_FAILURE_WaitingForReply:
self._rtcout.RTC_DEBUG("Retry pull message")
ret, cdr_data = dataservice.pull()
else:
raise
except BaseException:
raise

if ret == RTC.PORT_OK:
self._rtcout.RTC_DEBUG("get() successful")
Expand Down
16 changes: 13 additions & 3 deletions OpenRTM_aist/OutPortSHMConsumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
#
#


import omniORB
from omniORB import CORBA
import OpenRTM_aist
import OpenRTM
import OpenRTM__POA
from omniORB import CORBA

import threading

Expand Down Expand Up @@ -158,7 +158,17 @@ def get(self):
portshmem = self._ptr()

guard = OpenRTM_aist.ScopedLock(self._mutex)
ret = portshmem.get()

try:
ret = portshmem.get()
except CORBA.COMM_FAILURE as ex:
if ex.minor == omniORB.COMM_FAILURE_WaitingForReply:
self._rtcout.RTC_DEBUG("Retry get message")
ret = portshmem.get()
else:
raise
except BaseException:
raise

data = None

Expand Down
25 changes: 22 additions & 3 deletions OpenRTM_aist/OutPortSHMProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#
#


import omniORB
from omniORB import CORBA
import OpenRTM_aist
import OpenRTM

Expand Down Expand Up @@ -171,8 +172,26 @@ def get(self):
self._rtcout.RTC_TRACE(OpenRTM_aist.Logger.print_exception())
return OpenRTM.UNKNOWN_ERROR

self.setEndian(self._endian)
self.create_memory(self._memory_size, self._shm_address)
try:
self.setEndian(self._endian)
self.create_memory(self._memory_size, self._shm_address)
except CORBA.COMM_FAILURE as ex:
if ex.minor == omniORB.COMM_FAILURE_WaitingForReply:
self._rtcout.RTC_DEBUG("Retry set memory")
try:
self.setEndian(self._endian)
self.create_memory(self._memory_size, self._shm_address)
except BaseException:
self._rtcout.RTC_TRACE(
OpenRTM_aist.Logger.print_exception())
return OpenRTM.UNKNOWN_ERROR
else:
self._rtcout.RTC_TRACE(OpenRTM_aist.Logger.print_exception())
return OpenRTM.UNKNOWN_ERROR
except BaseException:
self._rtcout.RTC_TRACE(OpenRTM_aist.Logger.print_exception())
return OpenRTM.UNKNOWN_ERROR

if cdr:
self.write(cdr)

Expand Down
12 changes: 12 additions & 0 deletions OpenRTM_aist/PortBase.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import threading
import copy
import omniORB
from omniORB import CORBA

import OpenRTM_aist
import OpenRTM_aist.CORBA_RTCUtil
Expand Down Expand Up @@ -2305,6 +2307,16 @@ def checkPorts(self, ports):
if port._non_existent():
self._rtcout.RTC_WARN("Dead Port reference detected.")
return False
except CORBA.COMM_FAILURE as ex:
if ex.minor == omniORB.COMM_FAILURE_WaitingForReply:
self._rtcout.RTC_DEBUG("Retry access connected port")
if port._non_existent():
self._rtcout.RTC_WARN("Dead Port reference detected.")
return False
else:
self._rtcout.RTC_WARN(
OpenRTM_aist.Logger.print_exception())
return False
except BaseException:
self._rtcout.RTC_WARN(OpenRTM_aist.Logger.print_exception())
return False
Expand Down
Loading