Created
September 30, 2020 20:52
-
-
Save mariocesar/de47664bbdfb1c2c8cf2e42321241cd1 to your computer and use it in GitHub Desktop.
This file contains 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
from multiprocessing import Queue, Process | |
def do_something_really_slow(url): | |
... | |
result = Queue() | |
proc = Process(target=do_something_really_slow, args=(url,)) | |
proc.start() | |
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