Skip to content

Handle auto-created event loop when starting async spin#41

Closed
Suke0811 wants to merge 1 commit intomainfrom
codex/fix-event-loop-initialization-issue
Closed

Handle auto-created event loop when starting async spin#41
Suke0811 wants to merge 1 commit intomainfrom
codex/fix-event-loop-initialization-issue

Conversation

@Suke0811
Copy link
Owner

Summary

  • start async spinning on the auto-created event loop when no loop is running by launching the loop in a background thread
  • ensure asynchronous stop logic shuts down the owned loop and thread safely
  • add coverage to verify async spinning works without a pre-existing event loop

Testing

  • PYTHONPATH=. pytest tests/test_ratecontrol.py::test_start_spinning_async_with_auto_loop_thread -q

Codex Task

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +388 to 389
def start_spinning_async(self, func, condition_fn, *args, **kwargs):
"""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid awaiting spin task in wrapper

start_spinning_async is now a synchronous function that immediately returns the spin task (lines 388-389), but start_spinning_async_wrapper still does task = await self.start_spinning_async(...) with wait=False on line 438. Because the awaited object is the long-running spin task, the wrapper now blocks (and can propagate CancelledError) instead of returning immediately unless wait=True. Any async caller using the wrapper with the default wait=False will hang until the spin loop ends, which is a regression from the prior fire-and-forget behavior.

Useful? React with 👍 / 👎.

@Suke0811 Suke0811 closed this Nov 25, 2025
@Suke0811 Suke0811 deleted the codex/fix-event-loop-initialization-issue branch November 25, 2025 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant