def make_task(name, dependencies=(), should_succeed=True): """ Make a task that should succeed """ from arbiter.task import create_task function = succeed if should_succeed else fail return create_task(function, name=name, dependencies=dependencies)
def make_task(name, dependencies=(), should_succeed=True): """ Make a task """ from arbiter.task import create_task function = succeed if should_succeed else fail return create_task(lambda: executed_tasks.add(name) or function(), name=name, dependencies=dependencies)
def test_tasks_with_handler(): from arbiter.task import create_task from arbiter.sync import run_tasks from arbiter.utils import retry_handler foo = create_task( len, [1, 2, 3], handler=retry_handler(retries=5, delay=timedelta(), conditions=[]), ) run_tasks((foo, ))
def make_task(name, dependencies=(), should_succeed=True): """ Make a task """ from arbiter.task import create_task function = succeed if should_succeed else fail return create_task( lambda: executed_tasks.add(name) or function(), name=name, dependencies=dependencies )
def test_with_data(): """ Pass data. """ from arbiter.async import run_tasks from arbiter.task import create_task data = [4, 5, 6] def myfunc(val=-1): """ Modify some data which will be passed from another task. """ data.append(val) foo = create_task(len, [1, 2], name='foo') bar = create_task(myfunc, name='bar', val=foo) results = run_tasks((foo, bar), 2) assert_equals(results.exceptions, []) assert_equals(results.completed, frozenset(('foo', 'bar'))) assert_equals(data, [4, 5, 6, 2])
def test_tasks_with_handler(): from arbiter.task import create_task from arbiter.sync import run_tasks from arbiter.utils import retry_handler foo = create_task( len, [1, 2, 3], handler=retry_handler( retries=5, delay=timedelta(), conditions=[] ), ) run_tasks((foo,))
def create_task(name, dependencies=()): """ Create a task """ return task.create_task(None, name=name, dependencies=dependencies)