<s> """<STR_LIT>""" <EOL> from threading import Event <EOL> from tornado . concurrent import Future <EOL> class MessageFuture ( Future ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , msg_id , track = False ) : <EOL> super ( MessageFuture , self ) . __init__ ( ) <EOL> self . msg_id = msg_id <EOL> self . _evt = Event ( ) <EOL> self . track = track <EOL> self . _tracker = None <EOL> self . tracker = Future ( ) <EOL> if not track : <EOL> self . tracker . set_result ( None ) <EOL> self . add_done_callback ( lambda f : self . _evt . set ( ) ) <EOL> def wait ( self , timeout = None ) : <EOL> if not self . done ( ) : <EOL> return self . _evt . wait ( timeout ) <EOL> return True </s>
