Created
May 6, 2020 08:55
-
-
Save georgexsh/d2989c29c949bcc85f6596ccbd8aec2d to your computer and use it in GitHub Desktop.
queue_dead_lock.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import Queue | |
import threading | |
def f(q): | |
while True: | |
try: | |
q.get(block=False) | |
except Queue.Empty: | |
continue | |
q = Queue.Queue(2) | |
w = threading.Thread(target=f, args=(q,)) | |
w.daemon = True | |
w.start() | |
if os.fork() == 0: | |
r = q.put(1, timeout=1) | |
else: | |
r = os.wait() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment