[Python-checkins] cpython: Issue #12151: Test now ignores datagram socket errors after server is closed.

vinay.sajip python-checkins at python.org
Tue May 24 00:00:49 CEST 2011


http://hg.python.org/cpython/rev/1b1471d50b9e
changeset:   70318:1b1471d50b9e
user:        Vinay Sajip <vinay_sajip at yahoo.co.uk>
date:        Mon May 23 23:00:42 2011 +0100
summary:
  Issue #12151: Test now ignores datagram socket errors after server is closed.

files:
  Lib/test/test_logging.py |  21 +++++++++++----------
  1 files changed, 11 insertions(+), 10 deletions(-)


diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -888,7 +888,8 @@
                             before calling :meth:`start`, so that the server will
                             set up the socket and listen on it.
         """
-        def __init__(self, addr, handler, poll_interval=0.5, bind_and_activate=True):
+        def __init__(self, addr, handler, poll_interval=0.5,
+                     bind_and_activate=True):
             class DelegatingUDPRequestHandler(DatagramRequestHandler):
 
                 def handle(self):
@@ -896,15 +897,15 @@
 
                 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.server._closed), file=sys.stderr)
-                        raise
-
-            ThreadingUDPServer.__init__(self, addr, DelegatingUDPRequestHandler,
+                    if data:
+                        try:
+                            super(DelegatingUDPRequestHandler, self).finish()
+                        except socket.error:
+                            if not self.server._closed:
+                                raise
+
+            ThreadingUDPServer.__init__(self, addr,
+                                        DelegatingUDPRequestHandler,
                                         bind_and_activate)
             ControlMixin.__init__(self, handler, poll_interval)
             self._closed = False

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list