From: Fredrik Tolf Date: Sun, 5 Jan 2014 08:57:51 +0000 (+0100) Subject: python: Always properly close request handlers when exiting. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=c67f9f8bb7c20ab7c5a6fef9d69d3606f0ff144a;p=ashd.git python: Always properly close request handlers when exiting. --- diff --git a/python3/ashd-wsgi3 b/python3/ashd-wsgi3 index 79dda81..b250bce 100755 --- a/python3/ashd-wsgi3 +++ b/python3/ashd-wsgi3 @@ -192,5 +192,7 @@ class request(ashd.serve.wsgirequest): def handle(req): reqhandler.handle(request(bkreq=req, handler=reqhandler)) -ashd.util.serveloop(handle) -reqhandler.close() +try: + ashd.util.serveloop(handle) +finally: + reqhandler.close() diff --git a/python3/scgi-wsgi3 b/python3/scgi-wsgi3 index 1f5495d..946513e 100755 --- a/python3/scgi-wsgi3 +++ b/python3/scgi-wsgi3 @@ -132,9 +132,12 @@ class request(ashd.serve.wsgirequest): def close(self): self.sk.close() -while True: - nsk, addr = sk.accept() - try: - reqhandler.handle(request(sk=nsk, handler=reqhandler)) - finally: - nsk.close() +try: + while True: + nsk, addr = sk.accept() + try: + reqhandler.handle(request(sk=nsk, handler=reqhandler)) + finally: + nsk.close() +finally: + reqhandler.close()