You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
post_send fires after task execution with await_inplace=True #586
This breaks the semantic meaning of "post send". If I'm logging "task queued" in post_send, it ends up with a later timestamp than "task started" in pre_execute.
Is this intentional? If so, might be worth documenting. If not, the broker could call post_send before invoking the task inline.
Relevant log output
Broker initialization code
fromtaskiqimportInMemoryBroker, TaskiqMessagefromtaskiq.middlewaresimportSimpleRetryMiddlewarefromtaskiq.abc.middlewareimportTaskiqMiddlewareclassTaskLoggingMiddleware(TaskiqMiddleware):
asyncdef_log_event(self, message: TaskiqMessage, status: str) ->None:
# Inserts row to DB with created_at = now()# Problem: SENT rows end up with later timestamps than STARTED rows# because post_send fires after task execution with await_inplace=Truepassasyncdefpost_send(self, message: TaskiqMessage) ->None:
awaitself._log_event(message, "SENT")
asyncdefpre_execute(self, message: TaskiqMessage) ->TaskiqMessage:
awaitself._log_event(message, "STARTED")
returnmessagebroker=InMemoryBroker(await_inplace=True).with_middlewares(
TaskLoggingMiddleware(),
SimpleRetryMiddleware(default_retry_count=3),
)
Activity
fix(inmemory): stabilize task ordering and lifecycle
fix(inmemory): harden accepted task lifecycle