Skip to content

Commit 19e0d68

Browse files
committed
Wait until one event is processed or nothing done (timeout)
Signed-off-by: Jacob Perron <[email protected]>
1 parent 92bfb44 commit 19e0d68

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

launch/launch/launch_service.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,16 +349,23 @@ def _on_exception(loop, context):
349349

350350
# If there is an event in the queue, create a task to process it
351351
# and add it to the list of awaitables
352+
process_one_event_task = None
352353
if not self.__context._event_queue.empty():
353354
process_one_event_task = this_loop.create_task(self._process_one_event())
354355
entity_futures.append(process_one_event_task)
355356

356357
if len(entity_futures) > 0:
357-
done, pending = await asyncio.wait(
358-
entity_futures,
359-
timeout=1.0,
360-
return_when=asyncio.FIRST_COMPLETED
361-
)
358+
while True:
359+
done, pending = await asyncio.wait(
360+
entity_futures,
361+
timeout=1.0,
362+
return_when=asyncio.FIRST_COMPLETED
363+
)
364+
if process_one_event_task is not None:
365+
if process_one_event_task in done:
366+
break
367+
elif done:
368+
break
362369

363370
except KeyboardInterrupt:
364371
continue

0 commit comments

Comments
 (0)