Skip to content

Commit 03ffd64

Browse files
snopokeclaude
andcommitted
fix race condition in result.info access
result.info is a property that re-fetches from the backend on each access. Snapshot it into a local variable to prevent the value changing between the isinstance check and the .get() call. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e149e68 commit 03ffd64

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

taskbadger/celery.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ def apply_async(self, *args, **kwargs):
131131

132132
result = super().apply_async(*args, **kwargs)
133133

134-
tb_task_id = result.info.get(TB_TASK_ID) if isinstance(result.info, dict) else None
134+
info = result.info
135+
tb_task_id = info.get(TB_TASK_ID) if isinstance(info, dict) else None
135136
setattr(result, TB_TASK_ID, tb_task_id)
136137

137138
_get_task = functools.partial(get_task, tb_task_id) if tb_task_id else lambda: None

0 commit comments

Comments
 (0)