Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting a timeout for the start of the test server #625

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions cdci_data_analysis/pytest_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,8 @@
def start_dispatcher(rootdir, test_conf_fn, multithread=False, gunicorn=False):
clean_test_dispatchers()

timeout_sec_thread_start = 90

env = copy.deepcopy(dict(os.environ))
print(("rootdir", str(rootdir)))
env['PYTHONPATH'] = str(rootdir) + ":" + str(rootdir) + "/tests:" + \
Expand Down Expand Up @@ -777,13 +779,19 @@
print(f"{C}following server: server ready, url {url_store[0]}")


thread = Thread(target=follow_output, args=())
thread.start()
start_thread(target=follow_output)

started_waiting = time.time()
while url_store[0] is None:
print("waiting for server to start since", time.time() - started_waiting)
time.sleep(0.2)
waiting_time_for_start = time.time() - started_waiting
print(f"waiting for server to start since {waiting_time_for_start}")
if waiting_time_for_start > timeout_sec_thread_start:
print(f"timeout for starting the server reached, re-starting the thread")
kill_child_processes(p.pid, signal.SIGINT)
os.kill(p.pid, signal.SIGINT)
start_thread(target=follow_output)

Check warning on line 792 in cdci_data_analysis/pytest_fixtures.py

View check run for this annotation

Codecov / codecov/patch

cdci_data_analysis/pytest_fixtures.py#L789-L792

Added lines #L789 - L792 were not covered by tests
else:
time.sleep(0.2)
time.sleep(0.5)

service = url_store[0]
Expand All @@ -793,6 +801,9 @@
pid=p.pid
)

def start_thread(target):
thread = Thread(target=target, args=())
thread.start()

@pytest.fixture
def gunicorn_dispatcher_long_living_fixture(gunicorn_tmp_path, gunicorn_dispatcher, dispatcher_long_living_fixture):
Expand Down
Loading