Skip to content

Commit

Permalink
Make all test threads daemons to keep CI/CD from hanging.
Browse files Browse the repository at this point in the history
  • Loading branch information
lordjabez committed Mar 31, 2023
1 parent 59dfd8e commit 7be769b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
12 changes: 8 additions & 4 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,12 @@ def _calls_wait_for_calc_timeout_fast(res_queue):
res_queue = queue.Queue()
thread1 = threading.Thread(
target=_calls_wait_for_calc_timeout_fast,
kwargs={'res_queue': res_queue})
kwargs={'res_queue': res_queue},
daemon=True)
thread2 = threading.Thread(
target=_calls_wait_for_calc_timeout_fast,
kwargs={'res_queue': res_queue})
kwargs={'res_queue': res_queue},
daemon=True)

thread1.start()
thread2.start()
Expand Down Expand Up @@ -124,10 +126,12 @@ def _calls_wait_for_calc_timeout_slow(res_queue):
res_queue = queue.Queue()
thread1 = threading.Thread(
target=_calls_wait_for_calc_timeout_slow,
kwargs={'res_queue': res_queue})
kwargs={'res_queue': res_queue},
daemon=True)
thread2 = threading.Thread(
target=_calls_wait_for_calc_timeout_slow,
kwargs={'res_queue': res_queue})
kwargs={'res_queue': res_queue},
daemon=True)

thread1.start()
thread2.start()
Expand Down
24 changes: 18 additions & 6 deletions tests/test_memory_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,13 @@ def test_memory_being_calculated():
_takes_time.clear_cache()
res_queue = queue.Queue()
thread1 = threading.Thread(
target=_calls_takes_time, kwargs={'res_queue': res_queue})
target=_calls_takes_time,
kwargs={'res_queue': res_queue},
daemon=True)
thread2 = threading.Thread(
target=_calls_takes_time, kwargs={'res_queue': res_queue})
target=_calls_takes_time,
kwargs={'res_queue': res_queue},
daemon=True)
thread1.start()
sleep(0.5)
thread2.start()
Expand Down Expand Up @@ -206,9 +210,13 @@ def test_being_calc_next_time():
sleep(1.1)
res_queue = queue.Queue()
thread1 = threading.Thread(
target=_calls_being_calc_next_time, kwargs={'res_queue': res_queue})
target=_calls_being_calc_next_time,
kwargs={'res_queue': res_queue},
daemon=True)
thread2 = threading.Thread(
target=_calls_being_calc_next_time, kwargs={'res_queue': res_queue})
target=_calls_being_calc_next_time,
kwargs={'res_queue': res_queue},
daemon=True)
thread1.start()
sleep(0.5)
thread2.start()
Expand Down Expand Up @@ -240,9 +248,13 @@ def test_clear_being_calculated():
_takes_time.clear_cache()
res_queue = queue.Queue()
thread1 = threading.Thread(
target=_calls_takes_time, kwargs={'res_queue': res_queue})
target=_calls_takes_time,
kwargs={'res_queue': res_queue},
daemon=True)
thread2 = threading.Thread(
target=_calls_takes_time, kwargs={'res_queue': res_queue})
target=_calls_takes_time,
kwargs={'res_queue': res_queue},
daemon=True)
thread1.start()
_takes_time.clear_being_calculated()
sleep(0.5)
Expand Down
8 changes: 6 additions & 2 deletions tests/test_mongo_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,13 @@ def _takes_time(arg_1, arg_2):
_takes_time.clear_cache()
res_queue = queue.Queue()
thread1 = threading.Thread(
target=_calls_takes_time, kwargs={'res_queue': res_queue})
target=_calls_takes_time,
kwargs={'res_queue': res_queue},
daemon=True)
thread2 = threading.Thread(
target=_calls_takes_time, kwargs={'res_queue': res_queue})
target=_calls_takes_time,
kwargs={'res_queue': res_queue},
daemon=True)
thread1.start()
sleep(1)
thread2.start()
Expand Down
16 changes: 12 additions & 4 deletions tests/test_pickle_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,16 @@ def test_pickle_being_calculated(separate_files):
kwargs={
'takes_time_func': _takes_time_decorated,
'res_queue': res_queue,
}
},
daemon=True,
)
thread2 = threading.Thread(
target=_calls_takes_time,
kwargs={
'takes_time_func': _takes_time_decorated,
'res_queue': res_queue,
}
},
daemon=True,
)
thread1.start()
sleep(0.5)
Expand Down Expand Up @@ -271,14 +273,16 @@ def test_being_calc_next_time(separate_files):
kwargs={
'being_calc_func': _being_calc_next_time_decorated,
'res_queue': res_queue,
}
},
daemon=True,
)
thread2 = threading.Thread(
target=_calls_being_calc_next_time,
kwargs={
'being_calc_func': _being_calc_next_time_decorated,
'res_queue': res_queue,
}
},
daemon=True,
)
thread1.start()
sleep(0.5)
Expand Down Expand Up @@ -339,6 +343,7 @@ def _helper_bad_cache_file(sleeptime, separate_files):
'trash_cache': True,
'separate_files': separate_files,
},
daemon=True,
)
thread2 = threading.Thread(
target=_calls_bad_cache,
Expand All @@ -348,6 +353,7 @@ def _helper_bad_cache_file(sleeptime, separate_files):
'trash_cache': False,
'separate_files': separate_files,
},
daemon=True,
)
thread1.start()
sleep(sleeptime)
Expand Down Expand Up @@ -427,6 +433,7 @@ def _helper_delete_cache_file(sleeptime, separate_files):
'del_cache': True,
'separate_files': separate_files,
},
daemon=True,
)
thread2 = threading.Thread(
target=_calls_delete_cache,
Expand All @@ -436,6 +443,7 @@ def _helper_delete_cache_file(sleeptime, separate_files):
'del_cache': False,
'separate_files': separate_files,
},
daemon=True,
)
thread1.start()
sleep(sleeptime)
Expand Down

0 comments on commit 7be769b

Please sign in to comment.