mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #26404: Add context manager to socketserver, by Aviv Palivoda
This commit is contained in:
parent
7258176c68
commit
0cab9c1eba
11 changed files with 125 additions and 103 deletions
|
@ -378,6 +378,12 @@ class BaseServer:
|
|||
traceback.print_exc()
|
||||
print('-'*40, file=sys.stderr)
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, *args):
|
||||
self.server_close()
|
||||
|
||||
|
||||
class TCPServer(BaseServer):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue