Open jbweston opened 8 months ago
The Scheduler methods 'queue' and 'start_job' are blocking functions.
'start_new_jobs' is run in a ThreadPoolExecutor inside JobManager, but 'queue' is never run in a separate thread, and will block the event loop.
One fix would be to use 'asyncio.run_in_thread' everywhere these methods are called. An alternative is to make these methods async.
The first fix is easier to do, but also easier to footgun (forgetting to 'run_in_thread' impacts performance). Second fix would require more changes.
The reason I call start_new_jobs in a ThreadPoolExecutor is because when profiling, this part took a lot of time. queue seemed to be pretty fast.
start_new_jobs
ThreadPoolExecutor
queue
Open to all improvements though!
The Scheduler methods 'queue' and 'start_job' are blocking functions.
'start_new_jobs' is run in a ThreadPoolExecutor inside JobManager, but 'queue' is never run in a separate thread, and will block the event loop.
One fix would be to use 'asyncio.run_in_thread' everywhere these methods are called. An alternative is to make these methods async.
The first fix is easier to do, but also easier to footgun (forgetting to 'run_in_thread' impacts performance). Second fix would require more changes.