%PDF- %PDF-
Direktori : /usr/lib64/python2.7/site-packages/tornado/ |
Current File : //usr/lib64/python2.7/site-packages/tornado/locks.pyc |
� ��L]c @� s d Z d d l m Z m Z m Z m Z d d d d d g Z d d l Z d d l m Z m Z d d l m Z d e f d � � YZ d e f d � � YZ d e f d � � YZ d e f d � � YZ d e f d � � YZ d e f d � � YZ d e f d � � YZ d S( sd .. testsetup:: * from tornado import ioloop, gen, locks io_loop = ioloop.IOLoop.current() i ( t absolute_importt divisiont print_functiont with_statementt Conditiont Eventt Semaphoret BoundedSemaphoret LockN( t gent ioloop( t Futuret _TimeoutGarbageCollectorc B� s e Z d Z d � Z d � Z RS( s� Base class for objects that periodically clean up timed-out waiters. Avoids memory leak in a common pattern like: while True: yield condition.wait(short_timeout) print('looping....') c C� s t j � | _ d | _ d S( Ni ( t collectionst dequet _waiterst _timeouts( t self( ( s3 /usr/lib64/python2.7/site-packages/tornado/locks.pyt __init__) s c C� sM | j d 7_ | j d k rI d | _ t j d � | j D� � | _ n d S( Ni id i c s� s! | ] } | j � s | Vq d S( N( t done( t .0t w( ( s3 /usr/lib64/python2.7/site-packages/tornado/locks.pys <genexpr>3 s ( R R R R ( R ( ( s3 /usr/lib64/python2.7/site-packages/tornado/locks.pyt _garbage_collect- s ( t __name__t __module__t __doc__R R ( ( ( s3 /usr/lib64/python2.7/site-packages/tornado/locks.pyR s c B� sA e Z d Z d � Z d � Z d d � Z d d � Z d � Z RS( s� A condition allows one or more coroutines to wait until notified. Like a standard `threading.Condition`, but does not need an underlying lock that is acquired and released. With a `Condition`, coroutines can wait to be notified by other coroutines: .. testcode:: condition = locks.Condition() @gen.coroutine def waiter(): print("I'll wait right here") yield condition.wait() # Yield a Future. print("I'm done waiting") @gen.coroutine def notifier(): print("About to notify") condition.notify() print("Done notifying") @gen.coroutine def runner(): # Yield two Futures; wait for waiter() and notifier() to finish. yield [waiter(), notifier()] io_loop.run_sync(runner) .. testoutput:: I'll wait right here About to notify Done notifying I'm done waiting `wait` takes an optional ``timeout`` argument, which is either an absolute timestamp:: io_loop = ioloop.IOLoop.current() # Wait up to 1 second for a notification. yield condition.wait(timeout=io_loop.time() + 1) ...or a `datetime.timedelta` for a timeout relative to the current time:: # Wait up to 1 second. yield condition.wait(timeout=datetime.timedelta(seconds=1)) The method raises `tornado.gen.TimeoutError` if there's no notification before the deadline. c C� s) t t | � j � t j j � | _ d S( N( t superR R R t IOLoopt currentt io_loop( R ( ( s3 /usr/lib64/python2.7/site-packages/tornado/locks.pyR m s c C� s>