Skip to content

Commit e7f7144

Browse files
duanegYvesDup
andcommitted
Initialise synchronisation-related attributes in polymorphic method so each
class can do so as it requires. Co-authored-by: Duprat <yduprat@gmail.com>
1 parent 5b4dbb0 commit e7f7144

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

Lib/multiprocessing/popen_fork.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ def __init__(self, process_obj):
1818
util._flush_std_streams()
1919
self.returncode = None
2020
self.finalizer = None
21+
self._init_locking()
22+
self._launch(process_obj)
23+
24+
def _init_locking(self):
2125
self._exit_condition = threading.Condition()
2226
self._exit_blockers = 0
23-
self._launch(process_obj)
2427

2528
def duplicate_for_child(self, fd):
2629
return fd

Lib/multiprocessing/popen_forkserver.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ class Popen(popen_fork.Popen):
3333

3434
def __init__(self, process_obj):
3535
self._fds = []
36-
self._lock = threading.Lock()
3736
super().__init__(process_obj)
3837

38+
def _init_locking(self):
39+
self._lock = threading.Lock()
40+
3941
def duplicate_for_child(self, fd):
4042
self._fds.append(fd)
4143
return len(self._fds) - 1

0 commit comments

Comments
 (0)