Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Python 2.7-3.7.1 compatible NonDaemonPool #2754

Merged
merged 4 commits into from Oct 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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