Skip to content

Commit 0c904b5

Browse files
committed
create the resource_tracker before the manager
1 parent 3aef48e commit 0c904b5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Lib/multiprocessing/managers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import array
2222
import queue
2323
import time
24+
import os
2425
from os import getpid
2526

2627
from traceback import format_exc
@@ -1349,6 +1350,14 @@ class SharedMemoryManager(BaseManager):
13491350
_Server = SharedMemoryServer
13501351

13511352
def __init__(self, *args, **kwargs):
1353+
if os.name == "posix":
1354+
# bpo-36867: Ensure the resource_tracker is running before
1355+
# launching the manager process, so that concurrent
1356+
# shared_memory manipulation both in the manager and in the
1357+
# current process does not create two resource_tracker
1358+
# processes.
1359+
from . import resource_tracker
1360+
resource_tracker.ensure_running()
13521361
BaseManager.__init__(self, *args, **kwargs)
13531362
util.debug(f"{self.__class__.__name__} created by pid {getpid()}")
13541363

0 commit comments

Comments
 (0)