Skip to content

Instantly share code, notes, and snippets.

@pitrou
Created April 28, 2020 10:39
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 pitrou/d9784d5ec679059cd02fce4b38ea2fa6 to your computer and use it in GitHub Desktop.
Save pitrou/d9784d5ec679059cd02fce4b38ea2fa6 to your computer and use it in GitHub Desktop.
import faulthandler
from queue import Queue
import multiprocessing
import os
import sys
import threading
import time
if __name__ == "__main__":
queue = Queue()
def consume():
while True:
print("Consumed:", queue.get())
thread = threading.Thread(target=consume)
thread.start()
def proc():
faulthandler.dump_traceback_later(1.0, exit=True)
for i in range(10000):
queue.put(i)
p = multiprocessing.Process(target=proc)
p.start()
p.join()
if p.exitcode != 0:
print("Child process failed!")
os._exit(0)
print("Not hanging yet", i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment