Conversation
- Wraps `coordinator.import_entries` with `run_in_threadpool` in `marketplace_sources.py` - Prevents blocking the async event loop during artifact downloads (sync I/O) - Applied to both `import_artifacts` and `reimport_catalog_entry` endpoints - Reduces endpoint latency for concurrent requests significantly (from >1s to <0.01s during import) Co-authored-by: miethe <6800980+miethe@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Optimized the
import_artifactsandreimport_catalog_entryendpoints inskillmeat/api/routers/marketplace_sources.pyby offloading the synchronous, blockingcoordinator.import_entriescall to a thread pool usingstarlette.concurrency.run_in_threadpool.🎯 Why: The
ImportCoordinator.import_entriesmethod performs blocking network I/O (usingrequests) to download artifacts from GitHub. When called directly within anasync defFastAPI endpoint, this blocks the main event loop, preventing the server from handling other concurrent requests until the download completes. This degraded overall API responsiveness during imports.📊 Measured Improvement:
A reproduction script (
tests/reproduce_blocking.py) was used to simulate a blocking import operation (2s sleep) while concurrently sending a "ping" request.Existing tests (
tests/test_marketplace_catalog_repository.pyandtests/test_cache_marketplace.py) were run and passed, ensuring no regressions in related functionality. Some legacy tests (tests/test_cli_marketplace_integration.py) failed due to unrelated pre-existing issues (missingskillmanmodule), consistent with repository history.PR created automatically by Jules for task 10026217330691831741 started by @miethe