Skip to content

Commit a8a899b

Browse files
committed
ENH: Improve loop timing in DistributedPluginBase
1 parent d42ae1a commit a8a899b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

nipype/pipeline/plugins/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def run(self, graph, config, updatehash=False):
128128
old_progress_stats = None
129129
old_presub_stats = None
130130
while not np.all(self.proc_done) or np.any(self.proc_pending):
131+
loop_start = time()
131132
# Check to see if a job is available (jobs without dependencies not run)
132133
# See https://github.com/nipy/nipype/pull/2200#discussion_r141605722
133134
jobs_ready = np.nonzero(~self.proc_done & (self.depidx.sum(0) == 0))[1]
@@ -183,7 +184,8 @@ def run(self, graph, config, updatehash=False):
183184
elif display_stats:
184185
logger.debug('Not submitting (max jobs reached)')
185186

186-
sleep(poll_sleep_secs)
187+
sleep_til = loop_start + poll_sleep_secs
188+
sleep(max(0, sleep_til - time()))
187189

188190
self._remove_node_dirs()
189191
report_nodes_not_run(notrun)

0 commit comments

Comments
 (0)