<s> from threading import Condition , Lock <EOL> class Event ( object ) : <EOL> def __init__ ( self , ) : <EOL> self . __cond = Condition ( Lock ( ) ) <EOL> self . __flag = False <EOL> def isSet ( self ) : <EOL> return self . __flag <EOL> is_set = isSet <EOL> def set ( self ) : <EOL> self . __cond . acquire ( ) <EOL> try : <EOL> self . __flag = True <EOL> self . __cond . notify_all ( ) <EOL> finally : <EOL> self . __cond . release ( ) <EOL> def clear ( self ) : <EOL> self . __cond . acquire ( ) <EOL> try : <EOL> self . __flag = False <EOL> finally : <EOL> self . __cond . release ( ) <EOL> def wait ( self , timeout = None ) : <EOL> self . __cond . acquire ( ) <EOL> try : <EOL> if not self . __flag : <EOL> self . __cond . wait ( timeout ) <EOL> return self . __flag <EOL> finally : <EOL> self . __cond . release ( ) </s>
