diff options
Diffstat (limited to 'Lib/socketserver.py')
-rw-r--r-- | Lib/socketserver.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/socketserver.py b/Lib/socketserver.py index 2f39514..3e1f058 100644 --- a/Lib/socketserver.py +++ b/Lib/socketserver.py @@ -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): |