def releaseObject(self):
     try:
         self.stop()
     except Exception:
         self._log.exception("Error stopping")
     self.threadControlLock.acquire()
     try:
         ExecutableDevice.releaseObject(self)
     finally:
         self.threadControlLock.release()
Exemple #2
0
 def releaseObject(self):
     try:
         self.stop()
     except Exception:
         self._log.exception("Error stopping")
     self.threadControlLock.acquire()
     try:
         ExecutableDevice.releaseObject(self)
     finally:
         self.threadControlLock.release()
Exemple #3
0
class BasicTestDevice_python_impl1(CF__POA.AggregateExecutableDevice,
                                   ExecutableDevice, AggregateDevice):
    def __init__(self, devmgr, uuid, label, softwareProfile, compositeDevice,
                 execparams):
        ExecutableDevice.__init__(self, devmgr, uuid, label, softwareProfile,
                                  compositeDevice, execparams, PROPERTIES)
        AggregateDevice.__init__(self)

        self.process_thread = None
        self.__MAX_MEMORY = 2048
        self.__MAX_BOGOMIPS = 1024
        self.allocated_mem = 0
        self.allocated_bog = 0
        self.__mem_name = 'memCapacity'
        self.__bog_name = 'BogoMipsCapacity'
        self.__mem_id = 'DCE:7aeaace8-350e-48da-8d77-f97c2e722e06'
        self.__bog_id = 'DCE:bbdf708f-ce05-469f-8aed-f5c93e353e14'

    ###########################################
    # CF::LifeCycle
    ###########################################
    def initialize(self):
        ExecutableDevice.initialize(self)

    def start(self):
        ExecutableDevice.start(self)
        self.process_thread = ProcessThread(target=self.process,
                                            pause=self.PAUSE)
        self.process_thread.start()

    def process(self):
        return NOOP

    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")
        ExecutableDevice.stop(self)

    def releaseObject(self):
        try:
            self.stop()
        except Exception, e:
            if self._log != None:
                self._log.exception("Error stopping: ", e)
        ExecutableDevice.releaseObject(self)
class PythonExecDev_python_impl1_base(CF__POA.ExecutableDevice,
                                      ExecutableDevice):
    # 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):
        ExecutableDevice.__init__(self, devmgr, uuid, label, softwareProfile,
                                  compositeDevice, execparams)
        self.process_thread = None

    def initialize(self):
        ExecutableDevice.initialize(self)

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

    def releaseObject(self):
        try:
            self.stop()
        except Exception, e:
            self._log.exception("Error stopping: ", e)
        ExecutableDevice.releaseObject(self)
 def releaseObject(self):
     a = b
     ExecutableDevice.releaseObject(self)
 def releaseObject(self):
     try:
         self.stop()
     except Exception:
         self._log.exception("Error stopping")
     ExecutableDevice.releaseObject(self)
Exemple #7
0
 def releaseObject(self):
     a = b
     ExecutableDevice.releaseObject(self)