Task
Aioclock wrap your functions with a task object, and append the task to the list of tasks in the AioClock instance. After collecting all the tasks from decorated functions, aioclock serve them in order it has to be (startup, normal, shutdown).
These tasks keep running forever until the trigger's method should_trigger
returns False.
Task
dataclass
¶
Task(
func: Callable[..., Awaitable[Any]],
trigger: BaseTrigger,
id: UUID = uuid4(),
)
Task that will be run by AioClock.
Which always has a function and a trigger.
This is internally used, when you decorate your function with aioclock.task
.
Attributes:
Name | Type | Description |
---|---|---|
func |
Callable[..., Awaitable[Any]]
|
Callable[..., Awaitable[Any]]: Decorated function that will be run by AioClock. |
trigger |
BaseTrigger
|
BaseTrigger: Trigger that will be used to run the function. |
id |
UUID
|
UUID: Task ID that is unique for each task, and changes every time you run the aioclock app. In future we might store task ID in a database, so that it always remains same. |
run
async
¶
Run the task, and handle the exceptions. If the task fails, log the error with exception, but keep running the tasks.