File: patcher_existing_logging_module_lock.py

package info (click to toggle)
python-eventlet 0.40.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,200 kB
  • sloc: python: 25,101; sh: 78; makefile: 31
file content (24 lines) | stat: -rw-r--r-- 706 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# https://github.com/eventlet/eventlet/issues/730
# https://github.com/eventlet/eventlet/pull/754
__test__ = False


if __name__ == "__main__":
    import logging
    import threading

    handler = logging.Handler()
    logger = logging.Logger("test")
    logger.addHandler(handler)

    # Initially these are standard Python RLocks:
    assert not isinstance(logging._lock, threading._PyRLock)
    assert not isinstance(handler.lock, threading._PyRLock)

    # After patching, they get converted:
    import eventlet.patcher
    eventlet.patcher.monkey_patch(thread=True)
    assert isinstance(logging._lock, threading._PyRLock)
    assert isinstance(handler.lock, threading._PyRLock)

    print("pass")