Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(taskworker) Add concurrent worker (#83254)
Move the taskworker process to be a multiprocess concurrent worker. This will help enable higher CPU usage in worker pods, as we can pack more concurrent CPU operations into each pod (at the cost of memory). The main process is responsible for: - Spawning children - Making RPC requests to fill child queues and submit results. Each child process handles: - Resolving task names - Checking at_most_once keys - Enforcing processing deadlines - Executing task functions Instead of using more child processes to enforce timeouts, I've used SIGALRM. I've verified that tasks like ```python @exampletasks.register(name="examples.infinite", retry=Retry(times=2)) def infinite_task() -> None: try: while True: pass except Exception as e: print("haha caught exception", e) ``` Do not paralyze workers with infinite loops. When a worker is terminated, it uses an `Event` to have children exit, and then drains any results. If there are tasks in the `_child_tasks` queue will not be completed, and instead will sent to another worker when the `processing_deadline` on the activations expires. --------- Co-authored-by: Evan Hicks <evanh@users.noreply.github.com>
- Loading branch information