create_request_cls
Creates a specialized Request class for a specific task and execution pool, defining how the task is executed within the pool and how success or failure events are handled.
def create_request_cls(
base: class,
task: Task,
pool: TaskPool,
hostname: string,
eventer: EventDispatcher,
ref: callable,
revoked_tasks: set,
task_ready: callable,
trace: callable = None,
app: Celery = current_app
) - > class
Dynamically creates a specialized Request class tailored to a specific task and execution environment. This factory function captures task-specific configurations like time limits and acknowledgement policies to ensure the resulting Request instances behave correctly when executed in the worker pool.
Parameters
| Name | Type | Description |
|---|---|---|
| base | class | The base class from which the new Request class will inherit. |
| task | Task | The task instance providing configuration metadata such as time limits and acknowledgement settings. |
| pool | TaskPool | The execution pool used to asynchronously dispatch the task for processing. |
| hostname | string | The worker node's hostname used for identifying the source of task events. |
| eventer | EventDispatcher | The event dispatcher used to send real-time monitoring updates like success or failure notifications. |
| ref | callable | A reference-creation function, typically weakref.ref, used to track the task result without preventing garbage collection. |
| revoked_tasks | set | A collection of task IDs that have been cancelled and should not be executed. |
| task_ready | callable | A callback function triggered when a task completes its execution cycle. |
| trace | callable = None | The tracing function used to wrap the task execution; defaults to a fast or standard tracer based on app configuration. |
| app | Celery = current_app | The application instance providing configuration context for tracing and execution. |
Returns
| Type | Description |
|---|---|
class | A subclass of the provided base class, augmented with task-specific execution logic and event handling. |