Skip to content

Commit f373558

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 3e14a60 commit f373558

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
@@ -312,14 +312,14 @@ async def _async_wait_process(self, sleep_time):
312312
async def run_background_command(self, cmd, startup_check_delay=1, input=None, env=None):
313313
"""Runs the given background command, adds it to background_processes,
314314
and checks if the command is still running after startup_check_delay."""
315-
background_process = self.run_command(cmd, input, env)
316-
success_check_delay = self._async_wait_process(startup_check_delay)
315+
background_process = asyncio.ensure_future(self.run_command(cmd, input, env))
316+
success_check_delay = asyncio.ensure_future(self._async_wait_process(startup_check_delay))
317317

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

321321
# If the success check process is the one which exited first, all is good, else fail.
322-
if list(done)[0]._coro == success_check_delay:
322+
if success_check_delay in done:
323323
background_task = list(pending)[0]
324324
self.background_processes.append(background_task)
325325
return background_task

0 commit comments

Comments
 (0)