Commit 3ef1229b authored by Vinay Sajip's avatar Vinay Sajip

Issue #12151: Test now ignores datagram socket errors after server is closed.

parent 17ec7cd9
...@@ -888,7 +888,8 @@ if threading: ...@@ -888,7 +888,8 @@ if threading:
before calling :meth:`start`, so that the server will before calling :meth:`start`, so that the server will
set up the socket and listen on it. 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): class DelegatingUDPRequestHandler(DatagramRequestHandler):
def handle(self): def handle(self):
...@@ -896,15 +897,15 @@ if threading: ...@@ -896,15 +897,15 @@ if threading:
def finish(self): def finish(self):
data = self.wfile.getvalue() data = self.wfile.getvalue()
try: if data:
super(DelegatingUDPRequestHandler, self).finish() try:
except socket.error: super(DelegatingUDPRequestHandler, self).finish()
msg = ('Error during finish, while sending %r, ' except socket.error:
'closed = %s') if not self.server._closed:
print(msg % (data, self.server._closed), file=sys.stderr) raise
raise
ThreadingUDPServer.__init__(self, addr,
ThreadingUDPServer.__init__(self, addr, DelegatingUDPRequestHandler, DelegatingUDPRequestHandler,
bind_and_activate) bind_and_activate)
ControlMixin.__init__(self, handler, poll_interval) ControlMixin.__init__(self, handler, poll_interval)
self._closed = False self._closed = False
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment