perf: migrate to async architecture with Quart and optimize resource … #1860
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.



When submitting this pull request, I confirm the following (please check the boxes):
I have read and understood the Contributor Guidelines.
I have checked that there are no duplicate pull requests related to this request.
I have considered, and confirm that this submission is valuable to others.
I accept that this submission may not be used and the pull request may be closed at the discretion of the maintainers.
Fill in the PR content:
Summary
This PR refactors the Python RPC server to use async/await architecture, significantly improving performance, reducing memory and CPU usage, and enabling better concurrent request handling.
Changes
Framework Migration
Async Conversion
HttpDownloaderandHttpMultiLinkDownloaderto fully async operations usingasyncio.to_thread()for blocking I/OTorrentDownloaderto use async methods with proper thread pool executionProfileImageProcessorasync with proper context managers for memory-efficient image handlingPerformance Optimizations
asyncio.gather()for parallel status checks in multi-link downloadsCode Quality Improvements
Benefits
Testing
Dependencies
requirements.txt:flaskwithquartuvloop(Linux/Mac only, conditional import)Files Changed
python_rpc/http_downloader.py- Full async conversionpython_rpc/http_multi_link_downloader.py- Async with concurrent status checkspython_rpc/torrent_downloader.py- Async operations with optimized trackerspython_rpc/profile_image_processor.py- Async image processingpython_rpc/main.py- Complete rewrite using Quart with uvlooprequirements.txt- Updated dependencies