summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2022-06-11 17:07:29 -0700
committerBob Halley <halley@dnspython.org>2022-06-11 17:07:29 -0700
commit291d04c0359fe0be275924ccfc80d136db07e773 (patch)
tree1135a43a68ff92a0e9a36420ff0148a723db6c61 /tests
parentd9a690419419ef0e8b30e4aa6a41d65247e21f5f (diff)
downloaddnspython-291d04c0359fe0be275924ccfc80d136db07e773.tar.gz
deal with more windows idiosyncracies
Diffstat (limited to 'tests')
-rw-r--r--tests/nanonameserver.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/tests/nanonameserver.py b/tests/nanonameserver.py
index 7246e11..bc655ab 100644
--- a/tests/nanonameserver.py
+++ b/tests/nanonameserver.py
@@ -122,13 +122,15 @@ class Server(threading.Thread):
if self.port == 0 and self.enable_udp:
try:
self.tcp.bind((self.address, self.udp_address[1]))
- except OSError as e:
- if (
- e.errno == errno.EADDRINUSE
- and len(open_udp_sockets) < 100
- ):
+ except OSError:
+ # We can get EADDRINUSE and other errors like EPERM, so
+ # we just remember to close the UDP socket later, try again,
+ # and hope we get a better port. You'd think the OS would
+ # know better...
+ if len(open_udp_sockets) < 100:
open_udp_sockets.append(self.udp)
continue
+ # 100 tries to find a port is enough! Give up!
raise
else:
self.tcp.bind((self.address, self.port))