Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from concurrent.futures import ProcessPoolExecutor
- from multiprocessing import Lock
- class A:
- def __init__(self):
- """Uncomment the line blow to stuck in deadlock.
- """
- #self.lock = Lock() # deadlock
- def __call__(self):
- with ProcessPoolExecutor(4) as pool:
- future = pool.submit(self.job)#lambda x: print(x), 'hello')
- pool.shutdown()
- def job(self):
- print('hello, world')
- if __name__ == '__main__':
- A()()
Advertisement
Add Comment
Please, Sign In to add comment