pyronear / pyronear/pyro-annotator
Auto-annotate worker blocks the event loop on CPU inference
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 1
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 2
Description
Follow-up from #162 (detection-review chunk 1).
Observation
auto_annotate_sequence is an async procrastinate task, but its body runs synchronous, blocking work directly in the coroutine:
bucket.download_file(...)(sync boto3 S3 download)detector.predict(...)(CPU-bound ONNX inference)
These block the worker's event loop for the duration of each detection.
Impact
Harmless today: procrastinate's default concurrency is 1, so jobs run one at a time anyway and there is nothing else on the loop to starve. It only becomes a problem if worker concurrency is raised (--concurrency > 1) or multiple async tasks are expected to progress in parallel — then everything serializes behind the blocking inference.
Suggested fix (when/if concurrency is raised)
Offload the blocking calls to a thread executor, e.g. await asyncio.to_thread(detector.predict, img) and await asyncio.to_thread(bucket.download_file, key), so the loop stays responsive.
Notes
- No action needed while concurrency stays at 1; filing so it is not forgotten if the worker is scaled.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the auto_annotate_sequence procrastinate task and inspect its bucket.download_file and detector.predict calls. Confirm how worker concurrency is configured, then verify that CPU inference and S3 downloads no longer block other async work when concurrency exceeds 1.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- backend, cloud, machine-learning, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100