From 3ac1cdc3465d76faa63e35ddfddfaf187e38ffb8 Mon Sep 17 00:00:00 2001 From: William Bruneau Date: Fri, 26 Jul 2019 17:33:25 +0200 Subject: [PATCH] Make OneShotServer terminates after client connection ends --- rpyc/utils/server.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/rpyc/utils/server.py b/rpyc/utils/server.py index a4737544..a5851613 100644 --- a/rpyc/utils/server.py +++ b/rpyc/utils/server.py @@ -186,7 +186,7 @@ def _authenticate_and_serve_client(self, sock): sock.shutdown(socket.SHUT_RDWR) except Exception: pass - sock.close() + closing(sock) self.clients.discard(sock) def _serve_client(self, sock, credentials): @@ -286,8 +286,10 @@ class OneShotServer(Server): """ def _accept_method(self, sock): - with closing(sock): + try: self._authenticate_and_serve_client(sock) + finally: + self.close() class ThreadedServer(Server):