Skip to content

Commit bdf47e9

Browse files
authored
Make test_parallel_with_interactively_defined_functions_default_backend timeout more informatively on macos CI (#1332)
1 parent 54f4d21 commit bdf47e9

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

joblib/test/test_parallel.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,7 @@ def test_parallel_with_unpicklable_functions_in_args(
10321032

10331033
INTERACTIVE_DEFINED_FUNCTION_AND_CLASS_SCRIPT_CONTENT = """\
10341034
import sys
1035+
import faulthandler
10351036
# Make sure that joblib is importable in the subprocess launching this
10361037
# script. This is needed in case we run the tests from the joblib root
10371038
# folder without having installed joblib
@@ -1056,6 +1057,9 @@ def square(x, ignored=None, ignored2=None):
10561057
# Here, we do not need the `if __name__ == "__main__":` safeguard when
10571058
# using the default `loky` backend (even on Windows).
10581059
1060+
# To make debugging easier
1061+
faulthandler.dump_traceback_later(30, exit=True)
1062+
10591063
# The following baroque function call is meant to check that joblib
10601064
# introspection rightfully uses cloudpickle instead of the (faster) pickle
10611065
# module of the standard library when necessary. In particular cloudpickle is
@@ -1078,9 +1082,11 @@ def test_parallel_with_interactively_defined_functions_default_backend(tmpdir):
10781082
# filesystem script.
10791083
script = tmpdir.join('joblib_interactively_defined_function.py')
10801084
script.write(INTERACTIVE_DEFINED_FUNCTION_AND_CLASS_SCRIPT_CONTENT)
1081-
check_subprocess_call([sys.executable, script.strpath],
1082-
stdout_regex=r'\[0, 1, 4, 9, 16\]',
1083-
timeout=5)
1085+
check_subprocess_call(
1086+
[sys.executable, script.strpath],
1087+
stdout_regex=r'\[0, 1, 4, 9, 16\]',
1088+
timeout=None, # rely on faulthandler to kill the process
1089+
)
10841090

10851091

10861092
INTERACTIVELY_DEFINED_SUBCLASS_WITH_METHOD_SCRIPT_CONTENT = """\

joblib/testing.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ def kill_process():
5050
warnings.warn("Timeout running {}".format(cmd))
5151
proc.kill()
5252

53-
timer = threading.Timer(timeout, kill_process)
5453
try:
55-
timer.start()
54+
if timeout is not None:
55+
timer = threading.Timer(timeout, kill_process)
56+
timer.start()
5657
stdout, stderr = proc.communicate()
5758
stdout, stderr = stdout.decode(), stderr.decode()
5859
if proc.returncode != 0:
@@ -74,4 +75,5 @@ def kill_process():
7475
stderr_regex, stderr))
7576

7677
finally:
77-
timer.cancel()
78+
if timeout is not None:
79+
timer.cancel()

0 commit comments

Comments
 (0)