From d23d349e732b053708cce57672abf4600679392b Mon Sep 17 00:00:00 2001 From: Danijar Hafner Date: Thu, 12 Sep 2024 06:29:46 +0000 Subject: [PATCH] Flush error response before raise server error --- portal/__init__.py | 2 +- portal/server.py | 3 +++ portal/thread.py | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/portal/__init__.py b/portal/__init__.py index 8ba781a..0f0667d 100644 --- a/portal/__init__.py +++ b/portal/__init__.py @@ -1,4 +1,4 @@ -__version__ = '3.2.0' +__version__ = '3.2.1' import multiprocessing as mp try: diff --git a/portal/server.py b/portal/server.py index 44e995a..ab87fb8 100644 --- a/portal/server.py +++ b/portal/server.py @@ -148,4 +148,7 @@ def _error(self, addr, reqnum, status, message): data = message.encode('utf-8') self.socket.send(addr, reqnum, status, data) if self.errors: + # Wait until the error is delivered to the client and then raise. + self.socket.shutdown() + self.socket.close() raise RuntimeError(message) diff --git a/portal/thread.py b/portal/thread.py index b5e9028..ee57880 100644 --- a/portal/thread.py +++ b/portal/thread.py @@ -21,7 +21,6 @@ class Thread: """ def __init__(self, fn, *args, name=None, start=False): - global TIDS self.fn = fn self.excode = None name = name or getattr(fn, '__name__', 'thread')