|
34 | 34 | from __future__ import unicode_literals
|
35 | 35 |
|
36 | 36 | import errno
|
37 |
| -import sys |
38 |
| -import time |
39 |
| - |
40 |
| -import __main__ |
41 | 37 | import functools
|
42 | 38 | import os
|
43 | 39 | import random
|
44 | 40 | import re
|
45 | 41 | import shutil
|
46 | 42 | import socket
|
47 | 43 | import subprocess
|
| 44 | +import sys |
| 45 | +import time |
48 | 46 | from copy import copy
|
49 | 47 | from datetime import datetime
|
50 | 48 | from subprocess import PIPE, STDOUT
|
51 | 49 |
|
| 50 | +import __main__ |
| 51 | + |
52 | 52 | try:
|
53 | 53 | import queue as Queue # 3.x
|
54 | 54 | except ImportError:
|
@@ -202,10 +202,13 @@ def port_available(port, protocol_family='IPv4'):
|
202 | 202 | def wait_port(port, protocol_family='IPv4', **retry_kwargs):
|
203 | 203 | """Wait up to timeout for port (on host) to be connectable.
|
204 | 204 | Takes same keyword arguments as retry to control the timeout"""
|
| 205 | + |
205 | 206 | def check(e):
|
206 | 207 | """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 |
209 | 212 |
|
210 | 213 | host = None
|
211 | 214 |
|
@@ -381,7 +384,11 @@ def __init__(self, name=None, listen_port=None, wait=True,
|
381 | 384 | self.args += self.cl_args
|
382 | 385 | super(Http2Server, self).__init__(self.args, name=name, expect=expect)
|
383 | 386 | if wait:
|
384 |
| - self.wait_ready() |
| 387 | + try: |
| 388 | + self.wait_ready() |
| 389 | + except Exception: |
| 390 | + self.teardown() |
| 391 | + raise |
385 | 392 |
|
386 | 393 | def wait_ready(self, **retry_kwargs):
|
387 | 394 | """
|
@@ -506,7 +513,7 @@ def __init__(self, name=None, config=Config(), pyinclude=None, wait=True,
|
506 | 513 | elif env_home:
|
507 | 514 | args += ['-I', os.path.join(env_home, 'python')]
|
508 | 515 |
|
509 |
| - args = os.environ.get('QPID_DISPATCH_RUNNER', '').split() + args |
| 516 | + # args = ['rr', 'record'] + args |
510 | 517 | super(Qdrouterd, self).__init__(args, name=name, expect=expect)
|
511 | 518 | self._management = None
|
512 | 519 | self._wait_ready = False
|
@@ -534,6 +541,10 @@ def teardown(self):
|
534 | 541 | teardown_exc = None
|
535 | 542 | try:
|
536 | 543 | super(Qdrouterd, self).teardown()
|
| 544 | + # import psutil |
| 545 | + # for child in psutil.Process(pid=self.pid).children(): |
| 546 | + # child.terminate() |
| 547 | + # child.wait() |
537 | 548 | except Exception as exc:
|
538 | 549 | # re-raise _after_ dumping all the state we can
|
539 | 550 | teardown_exc = exc
|
|
0 commit comments