From b5192cca8ef32d89ab46ba98d231bb47aa1218a3 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Sun, 11 Dec 2022 19:51:53 -0500 Subject: [PATCH] Always greedily `list`-cast`mngrs` input sequence --- tractor/trionics/_mngrs.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tractor/trionics/_mngrs.py b/tractor/trionics/_mngrs.py index 09df201..b25c59a 100644 --- a/tractor/trionics/_mngrs.py +++ b/tractor/trionics/_mngrs.py @@ -109,6 +109,17 @@ async def gather_contexts( all_entered = trio.Event() parent_exit = trio.Event() + # XXX: ensure greedy sequence of manager instances + # since a lazy inline generator doesn't seem to work + # with `async with` syntax. + mngrs = list(mngrs) + + if not mngrs: + raise ValueError( + 'input mngrs is empty?\n' + 'Did try to use inline generator syntax?' + ) + async with trio.open_nursery() as n: for mngr in mngrs: n.start_soon(