Skip to content

Instantly share code, notes, and snippets.

@georgexsh
Created May 6, 2020 08:55
Show Gist options
  • Select an option

  • Save georgexsh/d2989c29c949bcc85f6596ccbd8aec2d to your computer and use it in GitHub Desktop.

Select an option

Save georgexsh/d2989c29c949bcc85f6596ccbd8aec2d to your computer and use it in GitHub Desktop.

Revisions

  1. georgexsh revised this gist May 6, 2020. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions queue_dead_lock.py
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,6 @@
    import threading




    def f(q):
    while True:
    try:
  2. georgexsh created this gist May 6, 2020.
    24 changes: 24 additions & 0 deletions queue_dead_lock.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    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()