@@ -60,6 +60,7 @@ def run_node(node, updatehash, taskid):
60
60
class NonDaemonProcess (Process ):
61
61
"""A non-daemon process to support internal multiprocessing.
62
62
"""
63
+
63
64
def _get_daemon (self ):
64
65
return False
65
66
@@ -104,6 +105,8 @@ class MultiProcPlugin(DistributedPluginBase):
104
105
- scheduler: sort jobs topologically (``'tsort'``, default value)
105
106
or prioritize jobs by, first, memory consumption and, second,
106
107
number of threads (``'mem_thread'`` option).
108
+ - maxtasksperchild: number of nodes to run on each process before
109
+ refreshing the worker (default: 10).
107
110
108
111
"""
109
112
@@ -116,6 +119,7 @@ def __init__(self, plugin_args=None):
116
119
117
120
# Read in options or set defaults.
118
121
non_daemon = self .plugin_args .get ('non_daemon' , True )
122
+ maxtasks = self .plugin_args .get ('maxtasksperchild' , 10 )
119
123
self .processors = self .plugin_args .get ('n_procs' , cpu_count ())
120
124
self .memory_gb = self .plugin_args .get ('memory_gb' , # Allocate 90% of system memory
121
125
get_system_total_memory_gb () * 0.9 )
@@ -124,7 +128,14 @@ def __init__(self, plugin_args=None):
124
128
# Instantiate different thread pools for non-daemon processes
125
129
logger .debug ('MultiProcPlugin starting in "%sdaemon" mode (n_procs=%d, mem_gb=%0.2f)' ,
126
130
'non' if non_daemon else '' , self .processors , self .memory_gb )
127
- self .pool = (NonDaemonPool if non_daemon else Pool )(processes = self .processors )
131
+
132
+ NipypePool = NonDaemonPool if non_daemon else Pool
133
+ try :
134
+ self .pool = NipypePool (processes = self .processors ,
135
+ maxtasksperchild = maxtasks )
136
+ except TypeError :
137
+ self .pool = NipypePool (processes = self .processors )
138
+
128
139
self ._stats = None
129
140
130
141
def _async_callback (self , args ):
0 commit comments