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.