File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ async def resolve_scheduler_request(
122122 start_time : float ,
123123 results_queue : Queue [WorkerProcessResult [RequestT , ResponseT ]],
124124 process_id : int ,
125+ stop_event : Event ,
125126 ) -> WorkerProcessRequest [RequestT , ResponseT ]:
126127 request = process_request .request
127128 timeout_time = process_request .timeout_time
@@ -142,8 +143,9 @@ async def resolve_scheduler_request(
142143 )
143144 asyncio .create_task (self .send_result (results_queue , result ))
144145
145- if (wait_time := start_time - time .time ()) > 0 :
146- await asyncio .sleep (wait_time )
146+ # Poll intermittently to check stop_event
147+ while not stop_event .is_set () and (wait_time := start_time - time .time ()) > 0 : # noqa: ASYNC110
148+ await asyncio .sleep (min (wait_time , 1 ))
147149
148150 info .worker_start = time .time ()
149151 result = WorkerProcessResult (
@@ -219,6 +221,7 @@ def _request_callback(
219221 start_time = start_time ,
220222 results_queue = queues .responses ,
221223 process_id = process_id ,
224+ stop_event = stop_event ,
222225 )
223226 )
224227 task .add_done_callback (_request_callback )
You can’t perform that action at this time.
0 commit comments