Skip to content

Commit 979b009

Browse files
committed
assert on number of threads left running after each test in config local test
1 parent 8345dcb commit 979b009

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

parsl/tests/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ def load_dfk_session(request, pytestconfig, tmpd_cwd_session):
180180
config = pytestconfig.getoption('config')[0]
181181

182182
if config != 'local':
183+
assert threading.active_count() == 1, "precondition: only one thread can be running before this test: " + repr(threading.enumerate())
184+
183185
spec = importlib.util.spec_from_file_location('', config)
184186
module = importlib.util.module_from_spec(spec)
185187
spec.loader.exec_module(module)
@@ -207,6 +209,9 @@ def load_dfk_session(request, pytestconfig, tmpd_cwd_session):
207209
raise RuntimeError("DFK changed unexpectedly during test")
208210
dfk.cleanup()
209211
assert DataFlowKernelLoader._dfk is None
212+
213+
assert threading.active_count() == 1, "test left threads running: " + repr(threading.enumerate())
214+
210215
else:
211216
yield
212217

@@ -233,6 +238,7 @@ def load_dfk_local_module(request, pytestconfig, tmpd_cwd_session):
233238
logger.error(f"BENC: start open fds: {start_fds}")
234239
logger.error(f"BENC: start threads: {threading.active_count()}")
235240

241+
assert threading.active_count() == 1, "precondition: only one thread can be running before this test"
236242
local_setup = getattr(request.module, "local_setup", None)
237243
local_teardown = getattr(request.module, "local_teardown", None)
238244
local_config = getattr(request.module, "local_config", None)
@@ -268,6 +274,8 @@ def load_dfk_local_module(request, pytestconfig, tmpd_cwd_session):
268274
logger.error(f"BENC: end open fds: {end_fds} (vs start {start_fds}")
269275
logger.error(f"BENC: end threads: {threading.active_count()}")
270276

277+
assert threading.active_count() == 1, "test left threads running: " + repr(threading.enumerate())
278+
271279
else:
272280
yield
273281

0 commit comments

Comments
 (0)