diff options
| author | Bob Halley <halley@dnspython.org> | 2022-06-11 17:07:29 -0700 |
|---|---|---|
| committer | Bob Halley <halley@dnspython.org> | 2022-06-11 17:07:29 -0700 |
| commit | 291d04c0359fe0be275924ccfc80d136db07e773 (patch) | |
| tree | 1135a43a68ff92a0e9a36420ff0148a723db6c61 /tests | |
| parent | d9a690419419ef0e8b30e4aa6a41d65247e21f5f (diff) | |
| download | dnspython-291d04c0359fe0be275924ccfc80d136db07e773.tar.gz | |
deal with more windows idiosyncracies
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/nanonameserver.py | 12 |
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)) |
