Created
May 6, 2020 08:55
-
-
Save georgexsh/d2989c29c949bcc85f6596ccbd8aec2d to your computer and use it in GitHub Desktop.
Revisions
-
georgexsh revised this gist
May 6, 2020 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,8 +3,6 @@ import threading def f(q): while True: try: -
georgexsh created this gist
May 6, 2020 .There are no files selected for viewing
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 charactersOriginal 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()