From bc6234e03226a60bb1d3c548198f9f4e6cc6c40a Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 31 Aug 2022 08:38:34 +0200 Subject: [PATCH] parallel socket shutdown --- copyparty/httpsrv.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/copyparty/httpsrv.py b/copyparty/httpsrv.py index cbd2defd..0c3795bd 100644 --- a/copyparty/httpsrv.py +++ b/copyparty/httpsrv.py @@ -278,12 +278,12 @@ class HttpSrv(object): except: pass + thrs = [] clients = list(self.clients) for cli in clients: - try: - cli.shutdown() - except: - pass + t = threading.Thread(target=cli.shutdown) + thrs.append(t) + t.start() if self.tp_q: self.stop_threads(self.tp_nthr) @@ -292,6 +292,9 @@ class HttpSrv(object): if self.tp_q.empty(): break + for t in thrs: + t.join() + self.log(self.name, "ok bye") def thr_client(self, sck: socket.socket, addr: tuple[str, int]) -> None: