@@ -180,6 +180,9 @@ def load_dfk_session(request, pytestconfig, tmpd_cwd_session):
180180    config  =  pytestconfig .getoption ('config' )[0 ]
181181
182182    if  config  !=  'local' :
183+         this_process  =  psutil .Process ()
184+         start_fds  =  this_process .num_fds ()
185+         logger .error (f"BENC: open fds: { start_fds }  " )
183186        assert  threading .active_count () ==  1 , "precondition: only one thread can be running before this test: "  +  repr (threading .enumerate ())
184187
185188        spec  =  importlib .util .spec_from_file_location ('' , config )
@@ -211,6 +214,9 @@ def load_dfk_session(request, pytestconfig, tmpd_cwd_session):
211214        assert  DataFlowKernelLoader ._dfk  is  None 
212215
213216        assert  threading .active_count () ==  1 , "test left threads running: "  +  repr (threading .enumerate ())
217+         end_fds  =  this_process .num_fds ()
218+         logger .error (f"BENC: end open fds: { end_fds }   (vs { start_fds }   at start)" )
219+         assert  start_fds  ==  end_fds , "number of open fds changed across test run" 
214220
215221    else :
216222        yield 
@@ -273,6 +279,12 @@ def load_dfk_local_module(request, pytestconfig, tmpd_cwd_session):
273279        logger .error (f"BENC: end open fds: { end_fds }   (vs start { start_fds }  " )
274280
275281        assert  threading .active_count () ==  1 , "test left threads running: "  +  repr (threading .enumerate ())
282+         end_fds  =  this_process .num_fds ()
283+         logger .error (f"BENC: open fds END: { end_fds }  " )
284+         if  end_fds  >  start_fds :
285+             logger .error (f"Open files (not all fds, though?): { this_process .open_files ()!r}  " )
286+             os .system (f"ls -l /proc/{ os .getpid ()}  /fd" )
287+             pytest .fail ("BENC: number of open fds increased across test" )
276288
277289    else :
278290        yield 
0 commit comments