Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement