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 2 commits into
base: main
Choose a base branch
from

Conversation

MtkN1
Copy link

@MtkN1 MtkN1 commented Oct 29, 2024

Fixes #178

Move asyncio.Event creation to lifespan

This PR moves the creation of the asyncio.Event from RebuildServer.__init__ to the Starlette lifespan to ensure it's created within the event loop context. This resolves the error we were seeing due to the event loop not being available during initialization.

Added a rebuild test

  • Executes the lifespan by opening TestClient in a context manager.
  • Modify test rst file and receives "refresh" from WebSocket.

Warning

Tests fail erratically.

There's a high probability that executing lifespan in the test code is causing pytest command to randomly fail after successful test runs. Please retry the CI. It's truly random: FATAL: exception not rethrown. I suspect this is due to the interaction between Starlette's TestClient, anyio threads, or related dependencies, but haven't found a solution yet.

nox > Running session test-3.10
nox > Creating virtual environment (virtualenv) using python3.10 in .nox/test-3-10
nox > python -m pip install -e '.[test]'
nox > pytest 
============================= test session starts ==============================
platform linux -- Python 3.10.15, pytest-8.3.3, pluggy-1.5.0
rootdir: /home/runner/work/sphinx-autobuild/sphinx-autobuild
configfile: pyproject.toml
plugins: anyio-4.6.2.post1
collected 7 items

tests/test_application.py .                                              [ 14%]
tests/test_ignore.py ......                                              [100%]

============================== 7 passed in 1.55s ===============================
FATAL: exception not rethrown
nox > Command pytest  failed with exit code -6
nox > Session test-3.10 failed.

While I'm satisfied with the test code itself, should I consider removing the test? Manual testing has been successful.

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