<s> from gevent . pool import Pool , Group <EOL> from lymph . exceptions import ResourceExhausted <EOL> class RejectExcecutionError ( ResourceExhausted ) : <EOL> pass <EOL> class NonBlockingPool ( Pool ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , timeout = None , ** kwargs ) : <EOL> super ( NonBlockingPool , self ) . __init__ ( ** kwargs ) <EOL> self . _timeout = timeout <EOL> def add ( self , greenlet ) : <EOL> acquired = self . _semaphore . acquire ( blocking = False , timeout = self . _timeout ) <EOL> if acquired is False : <EOL> raise RejectExcecutionError ( '<STR_LIT>' % greenlet ) <EOL> try : <EOL> Group . add ( self , greenlet ) <EOL> except : <EOL> self . _semaphore . release ( ) <EOL> raise </s>
