Created
May 6, 2019 04:19
-
-
Save ashiato45/0b5f32e5d6a9fb22888e29b7baceb0cf 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
import multiprocessing | |
import time | |
def f(x): | |
print("starting") | |
time.sleep(3) | |
print("ending") | |
return 1 | |
def g(x): | |
raise Exception("hoge") | |
if __name__ == "__main__": | |
multiprocessing.freeze_support() | |
with multiprocessing.Pool(processes=1) as pool: | |
res = pool.apply_async(f, (2,)) | |
print(res.get(timeout=4)) | |
res = pool.apply_async(g, (2,)) | |
print(res.get(timeout=1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment