@@ -23,9 +23,9 @@ def _resource_unlink(name, rtype):
23
23
resource_tracker ._CLEANUP_FUNCS [rtype ](name )
24
24
25
25
26
- def get_rtracker_pid ():
26
+ def get_rtracker_fd ():
27
27
resource_tracker .ensure_running ()
28
- return resource_tracker ._resource_tracker ._pid
28
+ return resource_tracker ._resource_tracker ._fd
29
29
30
30
31
31
class TestResourceTracker :
@@ -40,12 +40,12 @@ def test_resource_utils(self, rtype):
40
40
assert not resource_exists (name , rtype )
41
41
42
42
def test_child_retrieves_resource_tracker (self ):
43
- parent_rtracker_pid = get_rtracker_pid ()
43
+ parent_rtracker_fd = get_rtracker_fd ()
44
44
executor = ProcessPoolExecutor (max_workers = 2 )
45
- child_rtracker_pid = executor .submit (get_rtracker_pid ).result ()
45
+ child_rtracker_fd = executor .submit (get_rtracker_fd ).result ()
46
46
47
- # First simple pid retrieval check (see #200)
48
- assert child_rtracker_pid == parent_rtracker_pid
47
+ # First simple fd retrieval check (see #200)
48
+ assert child_rtracker_fd == parent_rtracker_fd
49
49
50
50
# Register a resource in the parent process, and un-register it in the
51
51
# child process. If the two processes do not share the same
@@ -294,15 +294,12 @@ def test_loky_process_inherit_multiprocessing_resource_tracker(self):
294
294
cmd = """if 1:
295
295
from loky import get_reusable_executor
296
296
from multiprocessing.shared_memory import SharedMemory
297
- from multiprocessing.resource_tracker import (
298
- _resource_tracker as mp_resource_tracker
299
- )
300
297
301
- def mp_rtracker_getattrs ():
298
+ def mp_rtracker_getfd ():
302
299
from multiprocessing.resource_tracker import (
303
300
_resource_tracker as mp_resource_tracker
304
301
)
305
- return mp_resource_tracker._fd, mp_resource_tracker._pid
302
+ return mp_resource_tracker._fd
306
303
307
304
308
305
if __name__ == '__main__':
@@ -312,9 +309,9 @@ def mp_rtracker_getattrs():
312
309
313
310
# loky forces the creation of the resource tracker at process
314
311
# creation so that loky processes can inherit its file descriptor.
315
- fd, pid = executor.submit(mp_rtracker_getattrs).result ()
316
- assert fd == mp_resource_tracker._fd
317
- assert pid == mp_resource_tracker._pid
312
+ parent_fd = mp_rtracker_getfd ()
313
+ child_fd = executor.submit(mp_rtracker_getfd).result()
314
+ assert child_fd == parent_fd
318
315
319
316
# non-regression test for #242: unlinking in a loky process a
320
317
# shared_memory segment tracked by multiprocessing and created its
@@ -326,5 +323,5 @@ def mp_rtracker_getattrs():
326
323
p = subprocess .run (
327
324
[sys .executable , "-c" , cmd ], capture_output = True , text = True
328
325
)
329
- assert not p .stdout
330
- assert not p .stderr
326
+ assert not p .stdout , p . stdout
327
+ assert not p .stderr , p . stderr
0 commit comments