Debian Codegraph @

tests/isolated/patcher_existing_logging_module_lock.py

raw
1 # https://github.com/eventlet/eventlet/issues/730
2 # https://github.com/eventlet/eventlet/pull/754
3 __test__ = False
4
5
6 if __name__ == "__main__":
7 import logging
8 import threading
9
10 handler = logging.Handler()
11 logger = logging.Logger("test")
12 logger.addHandler(handler)
13
14 # Initially these are standard Python RLocks:
15 assert not isinstance(logging._lock, threading._PyRLock)
16 assert not isinstance(handler.lock, threading._PyRLock)
17
18 # After patching, they get converted:
19 import eventlet.patcher
20 eventlet.patcher.monkey_patch(thread=True)
21 assert isinstance(logging._lock, threading._PyRLock)
22 assert isinstance(handler.lock, threading._PyRLock)
23
24 print("pass")