Issue #15064: Implement context manager protocol for multiprocessing types

This commit is contained in:
Richard Oudkerk 2012-06-18 17:47:52 +01:00
parent 0f884273b0
commit d69cfe88ea
6 changed files with 89 additions and 1 deletions

View file

@ -522,6 +522,12 @@ class Pool(object):
debug('cleaning up worker %d' % p.pid)
p.join()
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.terminate()
#
# Class whose instances are returned by `Pool.apply_async()`
#