Skip to content

fix(system): retain asyncio.create_task references to prevent GC - #808

Closed
CodeLine9 wants to merge 1 commit into
amd:mainfrom
CodeLine9:clawoss/fix/asyncio-task-gc
Closed

CodeLine9 wants to merge 1 commit into
amd:mainfrom
CodeLine9:clawoss/fix/asyncio-task-gc

Conversation

@CodeLine9

Copy link
Copy Markdown
Contributor

Bug

load-model and download-model endpoints call asyncio.create_task() without saving the reference. Per Python docs, the event loop only holds weak references to tasks — under GC pressure, the background download or load can be cancelled mid-stream.

Fix

Add a module-level _background_tasks set. Store each task reference and attach a done callback that discards it automatically.

Affected:

  • POST /api/system/load-model (line ~464)
  • POST /api/system/download-model (line ~493)

Closes #788

@CodeLine9

Copy link
Copy Markdown
Contributor Author

Closing — won't have bandwidth to address feedback on this. Apologies for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI server: fire-and-forget asyncio.create_task can be GC'd mid-operation

1 participant