Skip to content

Commit ac645ac

Browse files
committed
FIX: Restore NonDaemonProcess to file-level
1 parent 9eee003 commit ac645ac

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

nipype/pipeline/plugins/legacymultiproc.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,25 @@ def run_node(node, updatehash, taskid):
7373
# Return the result dictionary
7474
return result
7575

76+
# Pythons 2.7, 3.4-3.7.0, and 3.7.1 have three different implementations of
77+
# pool.Pool().Process(), but a common interface, so construct a Process and
78+
# subclass its __class__
79+
class NonDaemonProcess(pool.Pool().Process().__class__):
80+
@property
81+
def daemon(self):
82+
return False
83+
84+
@daemon.setter
85+
def daemon(self, val):
86+
pass
87+
7688

7789
class NonDaemonPool(pool.Pool):
7890
"""A process pool with non-daemon processes.
7991
"""
8092
def Process(self, *args, **kwds):
8193
proc = super(NonDaemonPool, self).Process(*args, **kwds)
82-
83-
class NonDaemonProcess(proc.__class__):
84-
"""Monkey-patch process to ensure it is never daemonized"""
85-
@property
86-
def daemon(self):
87-
return False
88-
89-
@daemon.setter
90-
def daemon(self, val):
91-
pass
94+
# Monkey-patch newly created processes to ensure they are never daemonized
9295
proc.__class__ = NonDaemonProcess
9396
return proc
9497

0 commit comments

Comments
 (0)