Skip to content

Commit

Permalink
Merge d7ab35f into 6006b54
Browse files Browse the repository at this point in the history
  • Loading branch information
saimn committed Jan 8, 2018
2 parents 6006b54 + d7ab35f commit 05a9a66
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
10 changes: 9 additions & 1 deletion doit/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from threading import Thread
import pickle
import queue
import time

import cloudpickle

Expand Down Expand Up @@ -411,8 +412,15 @@ def _run_start_processes(self, job_q, result_q):
# ### END DEBUG

proc_list = []
for _ in range(self.num_process):
for i in range(self.num_process):
next_job = self.get_next_job(None)
try:
delay = next_job.task_dict.get('delay') or 0
except AttributeError:
pass
else:
if i > 0 and delay:
time.sleep(delay)
if next_job is None:
break # do not start more processes than tasks
job_q.put(next_job)
Expand Down
5 changes: 4 additions & 1 deletion doit/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class Task(object):
'getargs': ((dict,), ()),
'title': ((types.FunctionType,), (None,)),
'watch': ((list, tuple), ()),
'delay': ((float, int), (None, )),
}


Expand All @@ -119,7 +120,7 @@ def __init__(self, name, actions, file_dep=(), targets=(),
is_subtask=False, has_subtask=False,
doc=None, params=(), pos_arg=None,
verbosity=None, title=None, getargs=None,
watch=(), loader=None):
watch=(), loader=None, delay=None):
"""sanity checks and initialization
@param params: (list of dict for parameters) see cmdparse.CmdOption
Expand All @@ -145,6 +146,7 @@ def __init__(self, name, actions, file_dep=(), targets=(),
self.check_attr(name, 'getargs', getargs, self.valid_attr['getargs'])
self.check_attr(name, 'title', title, self.valid_attr['title'])
self.check_attr(name, 'watch', watch, self.valid_attr['watch'])
self.check_attr(name, 'delay', delay, self.valid_attr['delay'])

if '=' in name:
msg = "Task '{}': name must not use the char '=' (equal sign)."
Expand Down Expand Up @@ -198,6 +200,7 @@ def __init__(self, name, actions, file_dep=(), targets=(),
self.teardown = [create_action(a, self) for a in teardown]
self.doc = self._init_doc(doc)
self.watch = watch
self.delay = delay


def _init_deps(self, file_dep, task_dep, calc_dep):
Expand Down

0 comments on commit 05a9a66

Please sign in to comment.