Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion taskiq/kicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ def with_labels(
self.labels.update(labels)
return self

def with_task_id(self, task_id: str) -> "AsyncKicker[_FuncParams, _ReturnType]":
def with_task_id(
self,
task_id: Optional[str],
) -> "AsyncKicker[_FuncParams, _ReturnType]":
"""
Set task_id for current execution.

Expand Down Expand Up @@ -208,6 +211,7 @@ async def schedule_by_cron(
labels=message.labels,
args=message.args,
kwargs=message.kwargs,
task_id=self.custom_task_id,
cron=cron_str,
cron_offset=cron_offset,
)
Expand Down Expand Up @@ -239,6 +243,7 @@ async def schedule_by_time(
labels=message.labels,
args=message.args,
kwargs=message.kwargs,
task_id=self.custom_task_id,
time=time,
)
await source.add_schedule(scheduled)
Expand Down
1 change: 1 addition & 0 deletions taskiq/scheduler/scheduled_task/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ScheduledTask(BaseModel):
labels: Dict[str, Any]
args: List[Any]
kwargs: Dict[str, Any]
task_id: Optional[str] = None
schedule_id: str = Field(default_factory=lambda: uuid.uuid4().hex)
cron: Optional[str] = None
cron_offset: Optional[Union[str, timedelta]] = None
Expand Down
1 change: 1 addition & 0 deletions taskiq/scheduler/scheduled_task/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class ScheduledTask(BaseModel):
labels: Dict[str, Any]
args: List[Any]
kwargs: Dict[str, Any]
task_id: Optional[str] = None
schedule_id: str = Field(default_factory=lambda: uuid.uuid4().hex)
cron: Optional[str] = None
cron_offset: Optional[Union[str, timedelta]] = None
Expand Down
1 change: 1 addition & 0 deletions taskiq/scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ async def on_ready(self, source: "ScheduleSource", task: ScheduledTask) -> None:
.with_labels(
schedule_id=task.schedule_id,
)
.with_task_id(task_id=task.task_id)
.kiq(
*task.args,
**task.kwargs,
Expand Down
Loading