def test_delay(): def sum_(a, b): return a+b assert hasattr(util.delay(sum_)(1, 2), '__call__') assert 3 == util.delay(sum_)(1, 2)() assert 3 == util.delay(sum_)(a=1, b=2)()
def enqueue(func, executor, config, target, after=None): """Enqueue the function on the executor if target doesn't exist. The function is expected to have been decorated by `@producer` and should have public interface of `(config, target_file)`. This function checks that the target file doesn't already exist and enqueues it with the correct parameters returning back the job id list. """ return [ executor.enqueue( delay(func)(config, target), tid=target, after=after)]