komuw / wiji

Wiji is an asyncio distributed task processor/queue.
MIT License
4 stars 1 forks source link

chained tasks should wait for max_retries of parents #9

Closed komuw closed 5 years ago

komuw commented 5 years ago

If we have something like:

MY_BROKER = wiji.broker.SimpleBroker()

class DividerTask(wiji.task.Task):
    async def run(self, a):
        res = a / 3
        print()
        print("RUNNING divider_task:")
        print("divider: ", res)
        print()
        return res

class AdderTask(wiji.task.Task):
    async def run(self, a, b):
        res = a + b
        print()
        print("RUNNING adder_task:")
        print("adder: ", res)
        print()
        await asyncio.sleep(2)
        return res

divider_task = DividerTask(the_broker=MY_BROKER, queue_name="DividerTaskQueue")
adder_task = AdderTask(the_broker=MY_BROKER, queue_name="AdderTaskQueue", chain=divider_task)

# call it
adder_task.synchronous_delay(3, 7, task_options=wiji.task.TaskOptions(eta=4.56, max_retries=3))

If the adder_task retries, then the divider_task(chained_task) should not run before retries are over.