mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #15064: Implement context manager protocol for multiprocessing types
This commit is contained in:
parent
0f884273b0
commit
d69cfe88ea
6 changed files with 89 additions and 1 deletions
|
@ -53,6 +53,12 @@ class Listener(object):
|
|||
|
||||
address = property(lambda self: self._backlog_queue)
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, exc_tb):
|
||||
self.close()
|
||||
|
||||
|
||||
def Client(address):
|
||||
_in, _out = Queue(), Queue()
|
||||
|
@ -85,3 +91,9 @@ class Connection(object):
|
|||
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, exc_tb):
|
||||
self.close()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue