Skip to content

Instantly share code, notes, and snippets.



Created Sep 30, 2020
What would you like to do?
from multiprocessing import Queue, Process
def do_something_really_slow(url):
result = Queue()
proc = Process(target=do_something_really_slow, args=(url,))
proc.join(timeout=5) # Wait 5 seconds, then timeout
if proc.exitcode != 0:
proc.kill() # Just in case
raise SystemError("We were unable to fetch the URL")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment