OwlCyberSecurity - MANAGER
Edit File: threadpool.pyc
� `��ac @` s� d Z d d l m Z m Z d d l Z d d l m Z d d l m Z m Z d d l m Z d d l m Z e � Z e d d d � � Y� Z d S( s� twisted.python.threadpool: a pool of threads to which we dispatch tasks. In most cases you can just use C{reactor.callInThread} and friends instead of creating a thread pool directly. i ( t divisiont absolute_importN( t pool( t logt context( t Failure( t _oldStylet 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 e e � Z d d d d � Z e d � � Z e d � � Z e d � � Z e d � � Z e 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. L{callInThread} and L{stop} should only be called from a single thread. @ivar started: Whether or not the thread pool is currently running. @type started: L{bool} @ivar threads: List of workers currently running in this thread pool. @type threads: L{list} @ivar _pool: A hook for testing. @type _pool: callable compatible with L{_pool} i i i c ` s� | d k s t d � � | | k s0 t d � � | � _ | � _ | � _ g � _ � f d � } � f d � } � j | | � � _ d S( sc Create a new threadpool. @param minthreads: minimum number of threads in the pool @type minthreads: L{int} @param maxthreads: maximum number of threads in the pool @type maxthreads: L{int} @param name: The name to give this threadpool; visible in log messages. @type name: native L{str} i s minimum is negatives minimum is greater than maximumc ` s2 � j d � j � | | � } � j j | � | S( Nt name( t threadFactoryt _generateNamet threadst append( t at kwt thread( t self( s\ /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/python/threadpool.pyt trackingThreadFactoryJ s c ` s � j s d S� j S( Ni ( t startedt max( ( R ( s\ /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/python/threadpool.pyt currentLimitO s N( t AssertionErrort minR R R t _poolt _team( R t minthreadst maxthreadsR R R ( ( R s\ /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/python/threadpool.pyt __init__6 s c C` s | j j � } | j | j S( s For legacy compatibility purposes, return a total number of workers. @return: the current number of workers, both idle and busy (but not those that have been quit by L{ThreadPool.adjustPoolsize}) @rtype: L{int} ( R t statisticst idleWorkerCountt busyWorkerCount( R t stats( ( s\ /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/python/threadpool.pyt workersW s c C` s d g | j j � j S( s� For legacy compatibility purposes, return the number of busy workers as expressed by a list the length of that number. @return: the number of workers currently processing a work item. @rtype: L{list} of L{None} N( t NoneR R R ( R ( ( s\ /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/python/threadpool.pyt workingd s c C` s d g | j j � j S( s, For legacy compatibility purposes, return the number of idle workers as expressed by a list the length of that number. @return: the number of workers currently alive (with an allocated thread) but waiting for new work. @rtype: L{list} of L{None} N( R! R R R ( R ( ( s\ /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/python/threadpool.pyt waitersp s c ` s# d t f � f d � � Y} | � S( s� For legacy compatibility purposes, return an object with a C{qsize} method that indicates the amount of work not yet allocated to a worker. @return: an object with a C{qsize} method. t NotAQueuec ` s e Z � f d � Z RS( c ` s � j j � j S( s Pretend to be a Python threading Queue and return the number of as-yet-unconsumed tasks. @return: the amount of backlogged work not yet dispatched to a worker. @rtype: L{int} ( R R t backloggedWorkCount( t q( R ( s\ /opt/cpanel-ccs/.develop/virtualenv/lib/python2.7/site-packages/twisted/python/threadpool.pyt qsize� s ( t __name__t __module__R'