def terminate(self, terminate_proxy = 0): if self.__debug and self.__verbose: print 'PyroProxy.terminate: %s terminating...' % self self.__stop = True self.__called.set() ## if this proxy is used within PyroGrid, ## PyroHandler.terminate will clean up by: ## ## 1. unregister Pyro URI from nameserver ## 2. close remote python process ## ## therefore terminate_proxy should be 0 if terminate_proxy: self.__pyro_lock.acquire() ## 1. unregister Pyro URI from nameserver and handler ## 2. leaves remote python process intact self.__pyro_proxy._release() self.__pyro_proxy._pyro_stop = True if not PyroUtils.is_stopped(self.__uri, ns = self.__nshost): PyroUtils.unregister(self.__uri, ns = self.__nshost) if hasattr(self, '_handler'): self._handler._release() self._handler.instance_uri = None while not self.__stopped: time.sleep(0.1)
def terminate(self): ## called from PyroProxy.terminate or on sys.exit (WatchDog call) if self.debug: print 'PyroHandler.terminate: %s terminating... ' % self ##--- call terminate only ## if the handler is already terminated (e.g. by hands) ## then function is not called on the exit topop = [atexit._exithandlers[i][0] == self.terminate for i in range(len(atexit._exithandlers))] if True in topop: atexit._exithandlers.pop( topop.index(True) ) ##--- unregister from the nameserver ## it will waits PyroUtils.default_timeout to let it ## finish self-unregistration if not self.instance_uri == None: PyroUtils.unregister(self.instance_uri, ns = self.nshost) ##--- shuts down remote process ## will leave interpreter alive if debug = True ## PyroHandler itself is an object instance managed ## by Pyro.core.Daemon, hence will be stopped by setting ## PyroHandler._pyro_stop to True self._pyro_stop = True