Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hot reloading for Python 3.9 #182

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

MtkN1
Copy link

@MtkN1 MtkN1 commented Oct 29, 2024

Fixes #178

1. Move asyncio.Event creation to lifespan

This PR moves the creation of the asyncio.Event from RebuildServer.__init__ to RebuildServer.lifespan. This ensures asyncio.Event is created within the event loop context, resolving the relevant error.

Note

The error does not occur in Python>=3.10 because the implementation was changed by python/cpython#86558.

2. Add rebuild test

Since there was no rebuild test, I added one.

  • Added a rebuild test.
    • Added a test to check refresh messages from /websocket-reload after modifying the index.rst file.
  • Changed the target test function to an asynchronous function.
    • Starlette's TestClient uses threads, while RebuildServer uses multiprocessing. In my view, this affected the rebuild test execution and cause it to fail. (0662fc9)
    • Changed Starlette's TestClient to http.AsyncClient. (ref)
    • Added test dependencies asgi-lifespan and httpx-ws required for testing lifespan and WebSocket.

Copy link
Author

@MtkN1 MtkN1 left a comment

Choose a reason for hiding this comment

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

After four months, the CI is finally green! ✅

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.

2024.09.03 - Autobuild does not hot reload when changes happen
1 participant