Skip to content

Commit cc66352

Browse files
committed
FIX: Non-daemon attribute as dynamic mixin
1 parent ac645ac commit cc66352

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

nipype/pipeline/plugins/legacymultiproc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ def run_node(node, updatehash, taskid):
7474
return result
7575

7676
# 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__):
77+
# pool.Pool().Process(), and the type of the result varies based on the default
78+
# multiprocessing context, so we need to dynamically patch the daemon property
79+
class NonDaemonMixin(object):
8080
@property
8181
def daemon(self):
8282
return False
@@ -92,7 +92,7 @@ class NonDaemonPool(pool.Pool):
9292
def Process(self, *args, **kwds):
9393
proc = super(NonDaemonPool, self).Process(*args, **kwds)
9494
# Monkey-patch newly created processes to ensure they are never daemonized
95-
proc.__class__ = NonDaemonProcess
95+
proc.__class__ = type('NonDaemonProcess', (NonDaemonMixin, proc.__class__), {})
9696
return proc
9797

9898

0 commit comments

Comments
 (0)