Skip to content

Commit

Permalink
fix: Missing notification of bgtask cancellation or failure when shut…
Browse files Browse the repository at this point in the history
…ting down the server (#2579)

Co-authored-by: Joongi Kim <joongi@lablup.com>
Backported-from: main (24.12)
Backported-to: 24.09
Backport-of: 2579
  • Loading branch information
jopemachine and achimnol committed Oct 24, 2024
1 parent 67e5531 commit a5d4d69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions changes/2579.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix missing notification of cancellation or failure of background tasks when shutting down the server
6 changes: 5 additions & 1 deletion src/ai/backend/common/bgtask.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ async def push_bgtask_events(
else:
await resp.send("{}", event="bgtask_done")
await resp.send("{}", event="server_close")
case BgtaskCancelledEvent() | BgtaskFailedEvent():
case BgtaskCancelledEvent():
await resp.send(json.dumps(body), event="bgtask_cancelled")
await resp.send("{}", event="server_close")
case BgtaskFailedEvent():
await resp.send(json.dumps(body), event="bgtask_failed")
await resp.send("{}", event="server_close")
except:
log.exception("")
Expand Down

0 comments on commit a5d4d69

Please sign in to comment.