ethereum / async-service

Lifecycle management for async Python applications
MIT License
9 stars 13 forks source link

External service call that runs a task throws an exception #33

Closed pipermerriam closed 4 years ago

pipermerriam commented 4 years ago

What is wrong

If a Service class exposes an API that calls self.manager.run_task the call will fail.

class MyService(Service):
    def schedule_thing(self):
        self.manager.run_task(self.do_thing)

This is because there is a check that the current task is part of the set of tasks which are already known to the service. In the above example, the current task will be external to the service and should not be cancelled upon service cancellation.

How can it be fixed.

I think that it makes the most sense to place these tasks in a separate container since they are detattched from the task DAG. I think it's appropriate to treat them as new root nodes in the DAG.