Current Path : /usr/lib/python2.7/dist-packages/twisted/python/ |
Current File : //usr/lib/python2.7/dist-packages/twisted/python/threadpool.pyc |
ó [³XMc @ s± d Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z m Z m Z d d l m Z d d l m Z e ƒ Z d d d „ ƒ YZ d d d „ ƒ YZ d S( s° twisted.threadpool: a pool of threads to which we dispatch tasks. In most cases you can just use reactor.callInThread and friends instead of creating a thread pool directly. iÿÿÿÿN( t logt contextt failure( t deprecatedModuleAttribute( t Versiont ThreadPoolc B sé e Z d Z d Z d Z e Z e Z d Z d Z e j Z e e j ƒ Z d d d d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d „ Z d d d „ Z d „ Z RS( s This class (hopefully) generalizes the functionality of a pool of threads to which work can be dispatched. callInThread() and stop() should only be called from a single thread, unless you make a subclass where stop() and _startSomeWorkers() are synchronized. i i i c C s| | d k s t d ƒ ‚ | | k s0 t d ƒ ‚ t j d ƒ | _ | | _ | | _ | | _ g | _ g | _ g | _ d S( s® Create a new threadpool. @param minthreads: minimum number of threads in the pool @param maxthreads: maximum number of threads in the pool i s minimum is negatives minimum is greater than maximumN( t AssertionErrort Queuet qt mint maxt namet waiterst threadst working( t selft minthreadst maxthreadsR ( ( s= /usr/lib/python2.7/dist-packages/twisted/python/threadpool.pyt __init__0 s c C s t | _ t | _ | j ƒ d S( s' Start the threadpool. N( t Falset joinedt Truet startedt adjustPoolsize( R ( ( s= /usr/lib/python2.7/dist-packages/twisted/python/threadpool.pyt startB s c C sj | j d 7_ d | j p$ t | ƒ | j f } | j d | j d | ƒ } | j j | ƒ | j ƒ d S( Ni s PoolThread-%s-%st targetR ( t workersR t idt threadFactoryt _workerR t appendR ( R R t newThread( ( s= /usr/lib/python2.7/dist-packages/twisted/python/threadpool.pyt startAWorkerK s "c C s# | j j t ƒ | j d 8_ d S( Ni ( R t putt WorkerStopR ( R ( ( s= /usr/lib/python2.7/dist-packages/twisted/python/threadpool.pyt stopAWorkerR s c C s&