def releaseObject(self): try: self.stop() except Exception: self._log.exception("Error stopping") self.threadControlLock.acquire() try: Device.releaseObject(self) finally: self.threadControlLock.release()
class simpleseqdev_python_impl1_base(CF__POA.Device, Device): # These values can be altered in the __init__ of your derived class PAUSE = 0.0125 # The amount of time to sleep if process return NOOP TIMEOUT = 5.0 # The amount of time to wait for the process thread to die when stop() is called DEFAULT_QUEUE_SIZE = 100 # The number of BulkIO packets that can be in the queue before pushPacket will block def __init__(self, devmgr, uuid, label, softwareProfile, compositeDevice, execparams): Device.__init__(self, devmgr, uuid, label, softwareProfile, compositeDevice, execparams) self.process_thread = None self.auto_start = False def initialize(self): Device.initialize(self) # Instantiate the default implementations for all ports on this component def start(self): Device.start(self) if self.process_thread == None: self.process_thread = ProcessThread(target=self.process, pause=self.PAUSE) self.process_thread.start() def process(self): """The process method should process a single "chunk" of data and then return. This method will be called from the processing thread again, and again, and again until it returns FINISH or stop() is called on the component. If no work is performed, then return NOOP""" raise NotImplementedError def stop(self): # Technically not thread-safe but close enough for now process_thread = self.process_thread self.process_thread = None if process_thread != None: process_thread.stop() process_thread.join(self.TIMEOUT) if process_thread.isAlive(): raise CF.Resource.StopError(CF.CF_NOTSET, "Processing thread did not die") Device.stop(self) def releaseObject(self): try: self.stop() except Exception, e: self._log.exception("Error stopping: " + str(e)) Device.releaseObject(self)
def releaseObject(self): try: self.stop() except Exception: self._log.exception("Error stopping") Device.releaseObject(self)