コード例 #1
0
 def releaseObject(self):
     try:
         self.stop()
     except Exception:
         self._log.exception("Error stopping")
     self.threadControlLock.acquire()
     try:
         Resource.releaseObject(self)
     finally:
         self.threadControlLock.release()
コード例 #2
0
 def releaseObject(self):
     try:
         self.stop()
     except Exception:
         self._log.exception("Error stopping")
     self.threadControlLock.acquire()
     try:
         Resource.releaseObject(self)
     finally:
         self.threadControlLock.release()
コード例 #3
0
class BasicAC_python_impl1_base(CF__POA.Resource, Resource):
    # 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, identifier, execparams):
        loggerName = execparams['NAME_BINDING'].replace('/', '.')
        Resource.__init__(self, identifier, execparams, loggerName=loggerName)
        self.process_thread = None

    def initialize(self):
        Resource.initialize(self)
        # Instantiate the default implementations for all ports on this component

        self.port_resourceOut = PortCFResourceOut_i(self, "resourceOut")

    def start(self):
        Resource.start(self)
        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")
        Resource.stop(self)

    def releaseObject(self):
        try:
            self.stop()
        except Exception, e:
            self._log.exception("Error stopping: " + str(e))
        Resource.releaseObject(self)
 def releaseObject(self):
     try:
         self.stop()
     except Exception:
         self._log.exception("Error stopping")
     Resource.releaseObject(self)
コード例 #5
0
 def releaseObject(self):
     try:
         self.stop()
     except Exception:
         self._log.exception("Error stopping")
     Resource.releaseObject(self)