Skip to content

Comments

fix: handle missing event loop in close() during interpreter shutdown#208

Open
haosenwang1018 wants to merge 1 commit intoHKUDS:mainfrom
haosenwang1018:fix/event-loop-finalize
Open

fix: handle missing event loop in close() during interpreter shutdown#208
haosenwang1018 wants to merge 1 commit intoHKUDS:mainfrom
haosenwang1018:fix/event-loop-finalize

Conversation

@haosenwang1018
Copy link

Closes #135

When the atexit handler calls close(), the default event loop policy may already be torn down during interpreter shutdown, causing asyncio.run() to raise RuntimeError: There is no current event loop in thread 'MainThread'.

This fix adds a fallback: if asyncio.run() fails, we manually create a new event loop with asyncio.new_event_loop() and run the finalization there. This ensures storages are properly finalized regardless of when the cleanup runs.

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.

[Bug]: Warning: Failed to finalize RAGAnything storages: There is no current event loop in thread 'MainThread'.

1 participant