def disconnect(self): # pragma: NO COVER ''' Implementation of IDL method. ''' global SINGLETON_CLIENT global ORB global POA_ROOT global POA_MANAGER global MGR_REF installTransientExceptionHandler(self, maxRetry) if self.token is not None: try: self.mgr.logout(self.token.h) except: pass finally: self.token = None #According to Duncan Grisby, maintainer of omniORBPy, #one should not use the textbook shutdown calls to #stop omniORBPy: # Having said that, you are using a particularly byzantine and awkward way # of shutting everything down. You should just call orb->shutdown(0) # inside your shutdown method. That destroys the POAs then shuts down the # ORB in one easy and convenient call. It will make your code much # simpler, and also avoid the race condition. #What he says should not be necessary at all but it #does seem to fix a bug in omniORBPy (some assertion error) #DWF - commented out the various shutdown calls for the #time being. if self.corbaRef is not None: try: self.corbaRef._release() except: pass finally: self.corbaRef = None #getPOAManager().deactivate(CORBA.TRUE, CORBA.TRUE) #getPOARoot().destroy(CORBA.TRUE, CORBA.TRUE) #getORB().shutdown(CORBA.TRUE) #getORB().shutdown(CORBA.FALSE) #getORB().destroy() ORB = None POA_ROOT = None POA_MANAGER = None MGR_REF = None SINGLETON_CLIENT = None return
def disconnect(self): # pragma: NO COVER ''' Implementation of IDL method. ''' global SINGLETON_CLIENT global ORB global POA_ROOT global POA_MANAGER global MGR_REF installTransientExceptionHandler(self, maxRetry) if self.token is not None: try: self.mgr.logout(self.token.h) except: pass finally: self.token=None #According to Duncan Grisby, maintainer of omniORBPy, #one should not use the textbook shutdown calls to #stop omniORBPy: # Having said that, you are using a particularly byzantine and awkward way # of shutting everything down. You should just call orb->shutdown(0) # inside your shutdown method. That destroys the POAs then shuts down the # ORB in one easy and convenient call. It will make your code much # simpler, and also avoid the race condition. #What he says should not be necessary at all but it #does seem to fix a bug in omniORBPy (some assertion error) #DWF - commented out the various shutdown calls for the #time being. if self.corbaRef is not None: try: self.corbaRef._release() except: pass finally: self.corbaRef=None #getPOAManager().deactivate(CORBA.TRUE, CORBA.TRUE) #getPOARoot().destroy(CORBA.TRUE, CORBA.TRUE) #getORB().shutdown(CORBA.TRUE) #getORB().shutdown(CORBA.FALSE) #getORB().destroy() ORB = None POA_ROOT = None POA_MANAGER = None MGR_REF = None SINGLETON_CLIENT = None return
def install_exception_handlers(): config.REMOTE_CALL_RETRY = 0 # wait 2^N seconds (N=5 -> approx 1 minute) # default handlers for remote calls errors def handle_REMOTE_CALL_ERROR(program,retries, exc): if retries >= config.REMOTE_CALL_RETRY: return False logger.warning('REMOTE_CALL_ERROR handler: waiting %ds %s',1<<retries,repr(exc)) time.sleep(1<<retries) return True omniORB.installTransientExceptionHandler(program,handle_REMOTE_CALL_ERROR) omniORB.installCommFailureExceptionHandler(program,handle_REMOTE_CALL_ERROR)
def connect(self): """Connect to the corba server and attach TRANSIENT error handler.""" orb_args = [] for orb_arg in self.orb_args: if isinstance(orb_arg, six.binary_type): warnings.warn( "Setting 'orb_args' as six.binary_type is deprecated. Please use six.text_type.", DeprecationWarning) if isinstance(orb_arg, six.text_type) and six.PY2: orb_arg = orb_arg.encode() elif isinstance(orb_arg, six.binary_type) and six.PY3: orb_arg = orb_arg.decode() orb_args.append(orb_arg) orb = CORBA.ORB_init(orb_args) obj = orb.string_to_object('corbaname::' + self.host_port) installTransientExceptionHandler(None, self.retry_handler, obj) self.context = obj._narrow(CosNaming.NamingContext)
if retries > 40: return False else: return True def systemFailure(cookie, retries, exc): if retries > 5: return False else: return True ENCODING = 'utf-8' cookie = None omniORB.installTransientExceptionHandler(cookie, transientFailure) omniORB.installCommFailureExceptionHandler(cookie, commFailure) omniORB.installSystemExceptionHandler(cookie, systemFailure) importIDL(whois.conf.get('corba', 'idl')) ccReg = sys.modules['ccReg'] registry = sys.modules['Registry'] # CORBA end def convertProperties(props, output): cproperties = [] if not props: return cproperties for key, value in props.iteritems():
else: return True def systemFailure(cookie, retries, exc): if retries > 5: return False else: return True ENCODING = 'utf-8' cookie = None omniORB.installTransientExceptionHandler(cookie, transientFailure) omniORB.installCommFailureExceptionHandler(cookie, commFailure) omniORB.installSystemExceptionHandler(cookie, systemFailure) importIDL(whois.conf.get('corba', 'idl')) ccReg = sys.modules['ccReg'] registry = sys.modules['Registry'] # CORBA end def convertProperties(props, output): cproperties = [] if not props: return cproperties