#NEWLINE# def wait( self , timeout = None ) : #NEWLINE# #INDENT# event = threading . Event ( ) #NEWLINE# self . _waiters [ threading . currentThread ( ) ] = [ timeout , None ] #NEWLINE# if ( timeout is not None ) : #NEWLINE# #INDENT# event . wait ( timeout ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# event . wait ( ) #NEWLINE# #UNINDENT# status = self . _waiters . pop ( threading . currentThread ( ) ) [ 1 ] #NEWLINE# if ( not event . isSet ( ) ) : #NEWLINE# #INDENT# raise self . Timeout #NEWLINE# #UNINDENT# if status : #NEWLINE# #INDENT# return self . _result #NEWLINE# #UNINDENT# raise self . WaitCancelled