Skip to content

fix(utils): close daemon event loops on shutdown - #9858

Open
RerankerGuo wants to merge 1 commit into
modelscope:mainfrom
RerankerGuo:fix/close-daemon-event-loop
Open

fix(utils): close daemon event loops on shutdown#9858
RerankerGuo wants to merge 1 commit into
modelscope:mainfrom
RerankerGuo:fix/close-daemon-event-loop

Conversation

@RerankerGuo

Copy link
Copy Markdown
Contributor

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

PR information

shutdown_event_loop_in_daemon stopped and joined the daemon thread but left
the event loop open. The stopped loop retained its selector and related
resources until garbage collection.

This PR closes the loop once its thread has exited. It also returns early for
an already closed loop, making repeated shutdown calls safe. If the thread
does not exit within the existing five-second timeout, the loop is not closed
from another thread.

The change is limited to the daemon event-loop lifecycle helper.

Experiment results

Before the fix:

{'thread_alive': False, 'loop_running': False, 'loop_closed': False}
FAILED (Runs=6, success=5, failures=1)

After the fix:

.venv/bin/python tests/run.py --pattern test_async_rewards.py
SUCCESS (Runs=6, success=6)

.venv/bin/pre-commit run --all-files
All hooks passed

Close the event loop after its daemon thread exits so selector and loop resources are released. Keep shutdown idempotent for already closed loops.

Test: .venv/bin/python tests/run.py --pattern test_async_rewards.py
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.

1 participant