Skip to content

Instantly share code, notes, and snippets.

@clayg
Created April 20, 2022 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clayg/1e2e4cb8f9fd35032fb56358f93754ec to your computer and use it in GitHub Desktop.
Save clayg/1e2e4cb8f9fd35032fb56358f93754ec to your computer and use it in GitHub Desktop.
See if green_existing_locks works?
import logging
import eventlet.patcher
eventlet.patcher.monkey_patch(thread=True)
import threading
def take_and_release():
try:
logging._lock.acquire()
finally:
logging._lock.release()
assert logging._lock.acquire()
t = threading.Thread(target=take_and_release)
t.start()
t.join(timeout=1)
# we should timeout, and the thread is still blocking
assert t.isAlive()
logging._lock.release()
t.join(timeout=1)
assert not t.isAlive()
print('locking works')
@tipabu
Copy link

tipabu commented Apr 20, 2022

Submitted that as eventlet/eventlet#754 -- FWIW, if I add

eventlet.patcher._fix_py3_rlock(logging._lock)

right after monkey patching, this guy seems happy on older py3 versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment