Skip to content

Commit

Permalink
Merge pull request #2754 from effigies/fix/multiproc37
Browse files Browse the repository at this point in the history
FIX: Python 2.7-3.7.1 compatible NonDaemonPool
  • Loading branch information
effigies committed Oct 25, 2018
2 parents 0c009ff + c9a787e commit 1dfc30d
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions nipype/pipeline/plugins/legacymultiproc.py
Expand Up @@ -11,7 +11,7 @@

# Import packages
import os
from multiprocessing import Process, Pool, cpu_count, pool
from multiprocessing import Pool, cpu_count, pool
from traceback import format_exception
import sys
from logging import INFO
Expand Down Expand Up @@ -74,23 +74,23 @@ def run_node(node, updatehash, taskid):
return result


class NonDaemonProcess(Process):
"""A non-daemon process to support internal multiprocessing.
"""

def _get_daemon(self):
return False

def _set_daemon(self, value):
pass

daemon = property(_get_daemon, _set_daemon)


class NonDaemonPool(pool.Pool):
"""A process pool with non-daemon processes.
"""
Process = NonDaemonProcess
def Process(self, *args, **kwds):
proc = super(NonDaemonPool, self).Process(*args, **kwds)

class NonDaemonProcess(proc.__class__):
"""Monkey-patch process to ensure it is never daemonized"""
@property
def daemon(self):
return False

@daemon.setter
def daemon(self, val):
pass
proc.__class__ = NonDaemonProcess
return proc


class LegacyMultiProcPlugin(DistributedPluginBase):
Expand Down

0 comments on commit 1dfc30d

Please sign in to comment.