summaryrefslogtreecommitdiff
path: root/tests/isolated/patcher_existing_locks_unlocked.py
blob: e6f1a911e0a7f3cc6e410ae4b850e83598c1f248 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
__test__ = False


def take(lock, e1, e2):
    with lock:
        e1.set()
        e2.wait()


if __name__ == '__main__':
    import sys
    import threading
    lock = threading.RLock()
    import eventlet
    eventlet.monkey_patch()

    lock.acquire()
    lock.release()

    e1, e2 = threading.Event(), threading.Event()
    eventlet.spawn(take, lock, e1, e2)
    e1.wait()
    assert not lock.acquire(blocking=0)
    e2.set()
    print('pass')