Ejemplo n.º 1
0
 def __del__(self):
     try: CObject._d_identifiers.remove(self._d_identifier)
     except Exception, e:
         log = logging.getLogger("PPLT.core")
         log.error("Unable to remove ID %s from list: [%s]"
                 %(_fmtid(self._d_identifier), self._d_identifiers))
         raise e
    def read(self, length):
        self._d_logger.debug("Try to read %i bytes..."%length);
        self._d_condition.acquire();
   
        if self.autolock(): self._reserve();

        if len(self._d_buffer)>0:
            self._d_logger.debug("return data (%i bytes) left in buffer..."%len(self._d_buffer));
            if length > len(self._d_buffer): length = len(self._d_buffer);
            data = self._d_buffer[0:length];
            self._d_buffer = self._d_buffer[length:];

            if self.autolock(): self._release();
            self._d_condition.release();
            return data;

        self._d_condition.wait(self._d_timeout);
        if len(self._d_buffer)==0:
            raise ItemBusy("Timeout while read from asyc source! (in %s)"%_fmtid(self.identifier()));

        if length > len(self._d_buffer): length = len(self._d_buffer);
        data = self._d_buffer[0:length];
        self._d_buffer = self._d_buffer[length:];
        
        if self.autolock(): self._release();
        self._d_condition.release();
        return data;
Ejemplo n.º 3
0
 def __init__(self):
     log = logging.getLogger("PPLT.core")
     self._d_identifier = self._make_id()
     while self._d_identifier in CObject._d_identifiers:
         self._d_identifier = self._make_id()
     CObject._d_identifiers.append(self._d_identifier)
     log.debug("Object (%s) created with ID %s"
             %(str(self), _fmtid(self._d_identifier)) )
Ejemplo n.º 4
0
 def autolock(self, status = None):
     """ This method will return the current status of the autolock 
         mechanism if no parameters is given. Other wise if the parameter 
         is  Ture the autolock mechanism will be enabled and if False it
         will be disabled. Please be care full using the autolock. Only
         if you are sure that all operations will consist of only on 
         method-call to the parent this may an option for you.
         
         B{Note:} The autolock mechanism ist disabled by default!"""
     
     if(status == None):
         return self._d_autolock
     
     if(not status in [True, False]):
         raise PPLTError("Only boolean values are allowed as parameters for autolock()")
     
     self._d_logger.info("Autolocking changed to %s for connetion %s!"%(status, _fmtid(self.identifier())))
     self._d_autolock = status
     
     return None
Ejemplo n.º 5
0
 def __del__(self):
     if self.is_busy():
         self._d_logger.warning("Destruction of module %s but is_busy() == True"%_fmtid(self.identifier()))
     CObject.__del__(self)