<s> """<STR_LIT>""" <EOL> from threading import Lock <EOL> from concoord . enums import * <EOL> from concoord . exception import * <EOL> class DLock ( ) : <EOL> def __init__ ( self ) : <EOL> self . __locked = False <EOL> self . __owner = None <EOL> self . __queue = [ ] <EOL> self . __atomic = Lock ( ) <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ , str ( self . __owner ) ) <EOL> def acquire ( self , _concoord_command ) : <EOL> with self . __atomic : <EOL> if self . __locked : <EOL> self . __queue . append ( _concoord_command ) <EOL> raise BlockingReturn ( ) <EOL> else : <EOL> self . __locked = True <EOL> self . __owner = _concoord_command . client <EOL> def release ( self , _concoord_command ) : <EOL> with self . __atomic : <EOL> if self . __owner != _concoord_command . client : <EOL> raise RuntimeError ( "<STR_LIT>" ) <EOL> if len ( self . __queue ) > <NUM_LIT:0> : <EOL> unblockcommand = self . __queue . pop ( <NUM_LIT:0> ) <EOL> self . __owner = unblockcommand . client <EOL> unblocked = { } <EOL> unblocked [ unblockcommand ] = True <EOL> raise UnblockingReturn ( unblockeddict = unblocked ) <EOL> elif len ( self . __queue ) == <NUM_LIT:0> : <EOL> self . __owner = None <EOL> self . __locked = False <EOL> def __str__ ( self ) : <EOL> return "<STR_LIT>" % ( self . __class__ . __name__ ) </s>
