<s> import sys <EOL> import logbook <EOL> class MyObject ( object ) : <EOL> def __init__ ( self , logger_func ) : <EOL> self . _logger_func = logger_func <EOL> def __str__ ( self ) : <EOL> self . _logger_func ( "<STR_LIT>" ) <EOL> return "<STR_LIT>" <EOL> class FakeLock ( object ) : <EOL> def __init__ ( self ) : <EOL> self . _acquired = False <EOL> self . _deadlock_occurred = False <EOL> def acquire ( self ) : <EOL> if self . _acquired : <EOL> self . _deadlock_occurred = True <EOL> self . _acquired = True <EOL> def release ( self ) : <EOL> self . _acquired = False <EOL> def test_deadlock_in_emit ( ) : <EOL> logbook_logger = logbook . Logger ( "<STR_LIT>" ) <EOL> obj = MyObject ( logbook_logger . info ) <EOL> stream_handler = logbook . StreamHandler ( stream = sys . stderr , <EOL> level = logbook . DEBUG ) <EOL> stream_handler . lock = FakeLock ( ) <EOL> with stream_handler . applicationbound ( ) : <EOL> logbook_logger . info ( "<STR_LIT>" , obj ) <EOL> assert not stream_handler . lock . _deadlock_occurred </s>
