Skip to content

Commit 46b153d

Browse files
committed
BatchSpawnerBase: Don't use internal API of asyncio.Tasks.
Wrapping the coroutines into futures first allows to directly check the state of the futures.
1 parent 3a6e57e commit 46b153d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

batchspawner/batchspawner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,14 @@ async def _async_wait_process(self, sleep_time):
286286
async def run_background_command(self, cmd, startup_check_delay=1, input=None, env=None):
287287
"""Runs the given background command, adds it to background_processes,
288288
and checks if the command is still running after startup_check_delay."""
289-
background_process = self.run_command(cmd, input, env)
290-
success_check_delay = self._async_wait_process(startup_check_delay)
289+
background_process = asyncio.ensure_future(self.run_command(cmd, input, env))
290+
success_check_delay = asyncio.ensure_future(self._async_wait_process(startup_check_delay))
291291

292292
# Start up both the success check process and the actual process.
293293
done, pending = await asyncio.wait([background_process, success_check_delay], return_when=asyncio.FIRST_COMPLETED)
294294

295295
# If the success check process is the one which exited first, all is good, else fail.
296-
if list(done)[0]._coro == success_check_delay:
296+
if success_check_delay in done:
297297
background_task = list(pending)[0]
298298
self.background_processes.append(background_task)
299299
return background_task

0 commit comments

Comments
 (0)