duck.http.core.httpd.task_executorยถ

Module containing RequestHandlingExecutor which handles execution of async coroutines and threaded tasks efficiently.

Module Contentsยถ

Classesยถ

RequestHandlingExecutor

A hybrid task executor for handling both async coroutines and blocking CPU-bound operations using threads efficiently.

APIยถ

class duck.http.core.httpd.task_executor.RequestHandlingExecutorยถ

A hybrid task executor for handling both async coroutines and blocking CPU-bound operations using threads efficiently.

Initialization

Initialize the RequestHandlingExecutor.

execute(task: Union[Callable, Coroutine])ยถ

Public interface to execute a task. It routes the task to either the async task queue or the thread pool, depending on its type.

Parameters:

task โ€“

The task to run.

  • If async, itโ€™s queued to run in event loop.

  • If sync, itโ€™s submitted to the thread pool.

on_task_complete(future: Union[concurrent.futures.Future, asyncio.Future])ยถ

Callback to handle completion or failure of a task.

Parameters:

future โ€“ Future object for the task.