Show
Ignore:
Timestamp:
05/28/07 18:47:32 (17 years ago)
Author:
jerome
Message:

Rewrote PJL accounter using threads and non-blocking I/O.
Move shared constants to a dedicated module.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/accounters/snmp.py

    r3163 r3175  
    2929""" 
    3030 
    31 ITERATIONDELAY = 4      # time to sleep between two loops 
    32 STABILIZATIONDELAY = 5  # number of consecutive times the idle status must be seen before we consider it to be stable 
    33 NOPRINTINGMAXDELAY = 60 # The printer must begin to print within 60 seconds by default. 
    3431 
    3532import sys 
     
    5249else : 
    5350    hasV4 = True 
     51 
     52from pykota import constants 
    5453 
    5554#                       
     
    158157            noprintingmaxdelay = int(self.parent.filter.config.getNoPrintingMaxDelay(self.parent.filter.PrinterName)) 
    159158        except (TypeError, AttributeError) : # NB : AttributeError in testing mode because I'm lazy ! 
    160             noprintingmaxdelay = NOPRINTINGMAXDELAY 
     159            noprintingmaxdelay = constants.NOPRINTINGMAXDELAY 
    161160            self.parent.filter.logdebug("No max delay defined for printer %s, using %i seconds." % (self.parent.filter.PrinterName, noprintingmaxdelay)) 
    162161        if not noprintingmaxdelay : 
     
    204203                            break 
    205204            self.parent.filter.logdebug(_("Waiting for printer %s to be printing...") % self.parent.filter.PrinterName)     
    206             time.sleep(ITERATIONDELAY) 
     205            time.sleep(constants.ITERATIONDELAY) 
    207206         
    208207    def waitIdle(self) : 
     
    226225                    return  
    227226                idle_num += 1 
    228                 if idle_num >= STABILIZATIONDELAY : 
     227                if idle_num >= constants.STABILIZATIONDELAY : 
    229228                    # printer status is stable, we can exit 
    230229                    break 
     
    232231                idle_num = 0 
    233232            self.parent.filter.logdebug(_("Waiting for printer %s's idle status to stabilize...") % self.parent.filter.PrinterName)     
    234             time.sleep(ITERATIONDELAY) 
     233            time.sleep(constants.ITERATIONDELAY) 
    235234             
    236235    def retrieveInternalPageCounter(self) :