Merge pull request #6 from DanielOaks/auto-server-start-wait

Automatically wait for server to start when connecting
This commit is contained in:
Valentin Lorentz
2015-12-20 13:51:14 +01:00
6 changed files with 15 additions and 11 deletions

View File

@ -2,7 +2,9 @@ import os
import shutil
import socket
import tempfile
import time
import subprocess
import psutil
from .optional_extensions import NotImplementedByController
@ -60,4 +62,11 @@ class BaseServerController(_BaseController):
raise NotImplementedError()
def registerUser(self, case, username):
raise NotImplementedByController('registration')
def wait_for_port(self, proc, port):
port_open = False
while not port_open:
time.sleep(0.1)
for conn in psutil.Process(proc.pid).connections():
if conn.laddr[1] == port:
port_open = True