Skip to content

Commit a2fe5ab

Browse files
committed
Python 3.9 shuffled the exception hierarchy, have to look for IOError, OSError one of which is common parent of both hierarchies
The change should've been API compatible, so that's not the reason for failing PR https://docs.python.org/3.9/library/socket.html#socket.error Python 3.9 shuffled the exception hierarchy, have to look for IOError, OSError one of which is common parent of both hierarchies The change should've been API compatible, so that's not the reason for failing PR https://docs.python.org/3.9/library/socket.html#socket.error Python 3.9 shuffled the exception hierarchy, have to look for IOError, OSError one of which is common parent of both hierarchies The change should've been API compatible, so that's not the reason for failing PR https://docs.python.org/3.9/library/socket.html#socket.error
1 parent 9469c4a commit a2fe5ab

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

tests/system_test.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,21 @@
3434
from __future__ import unicode_literals
3535

3636
import errno
37-
import sys
38-
import time
39-
40-
import __main__
4137
import functools
4238
import os
4339
import random
4440
import re
4541
import shutil
4642
import socket
4743
import subprocess
44+
import sys
45+
import time
4846
from copy import copy
4947
from datetime import datetime
5048
from subprocess import PIPE, STDOUT
5149

50+
import __main__
51+
5252
try:
5353
import queue as Queue # 3.x
5454
except ImportError:
@@ -202,10 +202,13 @@ def port_available(port, protocol_family='IPv4'):
202202
def wait_port(port, protocol_family='IPv4', **retry_kwargs):
203203
"""Wait up to timeout for port (on host) to be connectable.
204204
Takes same keyword arguments as retry to control the timeout"""
205+
205206
def check(e):
206207
"""Only retry on connection refused"""
207-
if not isinstance(e, socket.error) or not e.errno == errno.ECONNREFUSED:
208-
raise
208+
# TODO(DISPATCH-1539): in Python 3.3+ it is sufficient to catch only OSError
209+
if isinstance(e, (socket.error, IOError, OSError)) and e.errno == errno.ECONNREFUSED:
210+
return
211+
raise
209212

210213
host = None
211214

@@ -381,7 +384,11 @@ def __init__(self, name=None, listen_port=None, wait=True,
381384
self.args += self.cl_args
382385
super(Http2Server, self).__init__(self.args, name=name, expect=expect)
383386
if wait:
384-
self.wait_ready()
387+
try:
388+
self.wait_ready()
389+
except Exception:
390+
self.teardown()
391+
raise
385392

386393
def wait_ready(self, **retry_kwargs):
387394
"""
@@ -506,7 +513,7 @@ def __init__(self, name=None, config=Config(), pyinclude=None, wait=True,
506513
elif env_home:
507514
args += ['-I', os.path.join(env_home, 'python')]
508515

509-
args = os.environ.get('QPID_DISPATCH_RUNNER', '').split() + args
516+
# args = ['rr', 'record'] + args
510517
super(Qdrouterd, self).__init__(args, name=name, expect=expect)
511518
self._management = None
512519
self._wait_ready = False
@@ -534,6 +541,10 @@ def teardown(self):
534541
teardown_exc = None
535542
try:
536543
super(Qdrouterd, self).teardown()
544+
# import psutil
545+
# for child in psutil.Process(pid=self.pid).children():
546+
# child.terminate()
547+
# child.wait()
537548
except Exception as exc:
538549
# re-raise _after_ dumping all the state we can
539550
teardown_exc = exc

0 commit comments

Comments
 (0)