-
-
Notifications
You must be signed in to change notification settings - Fork 253
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
Deprecate on_shutdown
in favor of lifespan
(Fixes #397)
#398
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…o attribute 'is_capturing'' error on Windows. - 💄 Added new `screengear_error11.png` asset.
- 🏗️ Replaced deprecated Starlette's `on_shutdown` parameter with an async context manager `lifespan` in WebGear and WebGear_RTC APIs. - 🚚 Moved shutdown logic for VideoGear and peer RTC connections to this new `lifespan` context manager. - 📦️ Added new `contextlib` import for using `asynccontextmanager`. Docs: - 📝 Update README.md with changes to JPEG compression options - ✏️ Replaces deprecated options (`frame_jpeg_quality`, `frame_jpeg_optimize`, `frame_jpeg_progressive`) with their newer equivalents (`jpeg_compression_quality,` `jpeg_compression_fastdct`, `jpeg_compression_fastupsample`) in WebGear usage example.
4 tasks
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## testing #398 +/- ##
===========================================
- Coverage 93.56% 93.15% -0.41%
===========================================
Files 15 15
Lines 3013 3026 +13
===========================================
Hits 2819 2819
- Misses 194 207 +13 ☔ View full report in Codecov by Sentry. |
- 👷 Added new recommended approach of using `pytest.mark.asyncio(scope="module")` to mark all WebGear_RTC and NetGear_Async tests as asynchronous and utilize the same event loop throughout the module. - 🗑️ Deprecated custom `event_loop` fixture overrides in WebGear_RTC and NetGear_Async tests. - 🔥 Removed redundant `pytest.mark.asyncio` decorators from several test functions.
- ⚡️Modified `__init__` method to handle event loop more robustly: - Try to get the running event loop using `asyncio.get_running_loop()` - If no running event loop found, create a new one with `asyncio.new_event_loop()` - Log if creating a new event loop - 🧑💻 Changed launch method to use `self.loop.create_task()` instead of `asyncio.ensure_future()` - Ensures the task is created using the correct event loop instance.
- ⚡️ Moved the event loop initialization code to an earlier point before setting event loop policy to ensure it is set up correctly before selecting `WindowsSelectorEventLoop` policy. - 💬 Background: On Windows, vidgear requires the `WindowsSelectorEventLoop`, but Python 3.8 and above defaults to the `ProactorEventLoop` which is not compatible. - 🔥 Removed redundant python version check to set `WindowsSelectorEventLoop` policy, as minimum supported version is already `3.8`. - 💡 Updated code comments.
- 🐛 Replaced buggy kofi widget with a button image in index.md - 🏗️ Remove script tags from main.html and use a custom hook for adding JS - 🔥 Remove site.webmanifest file - 💄 Update mkdocs.yml with new configuration settings: - Set edit_uri for GitHub edit links - Add new theme features like content actions, tooltips, etc. - Update palette settings for light/dark mode - Enable new markdown extensions - Add custom JS hook for adding scripts on certain pages - ♻️ Other minor tweaks and cleanups
- 👷 Add a new event_loop_policy fixture for pytest to override the event loop policy - 🔊 Log the event loop being used for debugging - 🔧 Mark the new fixture in relevant test functions with pytest.mark.asyncio(scope="module") - ♻️ Remove unused imports and code cleanup NetGear_Async: - ⚡️ Move event loop setup and policy assignment to the beginning of `__init__` before zmq Context creation.
- 🧑💻 Refactored all APIs and bonus examples to use linenums and hl_lines - Makes it easier to highlight specific lines in code blocks - 📝 Updated remaining code examples for picamera2 and legacy picamera backends - 🐛 Replaced buggy kofi widget with a button image in `help.md` - 💄 Update announcement icon in `main.html` - 💄 Change system mode toggle icon and name in `mkdocs.yml`
…ra=True` on unsupported system - ⚡️ Instead of silently disabling `picamera2` API directly, PiGear now raises an error if `picamera` is unavailable or unsupported - 🥅 Prevented incorrect initialization of `PiGear` class on unsupported 64-bit OS systems. Docs: - 📝 Add failure warning in various docs about `picamera` incompatibility on 64-bit OS
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
DOCS 📜
Issue/PR is related to vidgear docs.
ENHANCEMENT ⚡
New Feature/Addition/Improvement
SOLVED 🏁
This issue/PR is resolved now. Goal Achieved!
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Brief Description
This PR proposes to deprecate the
on_shutdown
hooks in Starlette, in favor of the more robust and recommendedlifespan
approach. Thelifespan
approach provides a more structured and reliable way to handle startup and shutdown tasks, and it is recommended by the ASGI specification (https://asgi.readthedocs.io/en/latest/specs/lifespan.html).Requirements / Checklist
Related Issue
#397
Context
Currently, In APIs like WebGear, Starlette uses
on_shutdown
hooks for running shutdown task. However, this hooks have certain limitations and are not as robust as thelifespan
approach, which uses async context managers. This PR will removeon_shutdown
hooks in Starlette in favor of the more robust and recommendedlifespan
approach.Types of changes