Problem
create_batch_remediation() in batch.py:25 calls PlatformService.process_batch_job() synchronously inside an async endpoint:
PlatformService.process_batch_job(job_data)
This blocks the entire event loop for the duration of the batch, preventing the server from handling any other requests. For a batch of many devices, this could block for a significant time.
The docs describe batch processing as "parallel," but the implementation is sequential and blocking.
Suggested Fix
- Use
asyncio.to_thread() or FastAPI's BackgroundTasks to run batch processing off the event loop.
- Return a 202 Accepted with the job ID immediately, and let the client poll
/batch/jobs/{id} for status.
- Consider
concurrent.futures.ProcessPoolExecutor for true parallelism across devices.
Problem
create_batch_remediation()inbatch.py:25callsPlatformService.process_batch_job()synchronously inside anasyncendpoint:This blocks the entire event loop for the duration of the batch, preventing the server from handling any other requests. For a batch of many devices, this could block for a significant time.
The docs describe batch processing as "parallel," but the implementation is sequential and blocking.
Suggested Fix
asyncio.to_thread()or FastAPI'sBackgroundTasksto run batch processing off the event loop./batch/jobs/{id}for status.concurrent.futures.ProcessPoolExecutorfor true parallelism across devices.