diff options
Diffstat (limited to 'test/functional/lib/rspamd.py')
-rw-r--r-- | test/functional/lib/rspamd.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/test/functional/lib/rspamd.py b/test/functional/lib/rspamd.py index 89e79aec8..bfad7d61d 100644 --- a/test/functional/lib/rspamd.py +++ b/test/functional/lib/rspamd.py @@ -1,5 +1,6 @@ import demjson import grp +import ipaddress import os import os.path import psutil @@ -155,4 +156,26 @@ def shutdown_process_with_children(pid): children = psutil.Process(pid=pid).children(recursive=False) shutdown_process(pid) for child in children: - shutdown_process(child.pid) + try: + shutdown_process(child.pid) + except: + pass + +def wait_for_port(proto, addr, num): + i = ipaddress.ip_address(addr) + if (i.version == 6): + af = socket.AF_INET6 + else: + af = socket.AF_INET + while True: + try: + s = socket.socket(af, proto) + s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + s.bind((addr, num)) + if (proto == socket.SOCK_STREAM): + s.listen(0) + break + except: + pass + time.sleep(0.1) + s.close() |