From ba980db797892e771e9d66e9bd0468cdd2c73115 Mon Sep 17 00:00:00 2001 From: Vinay Sajip Date: Mon, 23 May 2011 21:37:54 +0100 Subject: [PATCH] Issue #12151: Added diagnostics to help diagnose intermittent socket errors. --- Lib/test/test_logging.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 3118065a76c..6c66ff109cc 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -893,14 +893,29 @@ if threading: def handle(self): self.server._handler(self) + + def finish(self): + data = self.wfile.getvalue() + try: + super(DelegatingUDPRequestHandler, self).finish() + except socket.error: + msg = ('Error during finish, while sending %r, ' + 'closed = %s') + print(msg % (data, self._closed), file=sys.stderr) + raise + ThreadingUDPServer.__init__(self, addr, DelegatingUDPRequestHandler, bind_and_activate) ControlMixin.__init__(self, handler, poll_interval) + self._closed = False def server_bind(self): super(TestUDPServer, self).server_bind() self.port = self.socket.getsockname()[1] + def server_close(self): + super(TestUDPServer, self).server_close() + self._closed = True # - end of server_helper section