Handle awaitables on sous to avoid warnings
This commit is contained in:
parent
3cf9b2bcec
commit
f17b17d02a
@ -16,10 +16,12 @@
|
||||
# along with Scone. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import asyncio
|
||||
import itertools
|
||||
import logging
|
||||
import os
|
||||
import pwd
|
||||
import sys
|
||||
from itertools import filterfalse
|
||||
from pathlib import Path
|
||||
from typing import List, cast
|
||||
|
||||
@ -76,6 +78,8 @@ async def main(args: List[str]):
|
||||
|
||||
logger.info("Worktop dir is: %s", worktop.dir)
|
||||
|
||||
awaitables = []
|
||||
|
||||
while True:
|
||||
try:
|
||||
message = await root.recv()
|
||||
@ -94,7 +98,7 @@ async def main(args: List[str]):
|
||||
|
||||
logger.debug("going to sched task with %r", utensil)
|
||||
|
||||
asyncio.create_task(run_utensil(utensil, channel, worktop))
|
||||
awaitables.append(asyncio.create_task(run_utensil(utensil, channel, worktop)))
|
||||
elif "lost" in message:
|
||||
# for a then-non-existent channel, but probably just waiting on us
|
||||
# retry without a default route.
|
||||
@ -102,6 +106,14 @@ async def main(args: List[str]):
|
||||
else:
|
||||
raise RuntimeError(f"Unknown ch0 message {message}")
|
||||
|
||||
for done_aw in filter(lambda aw: aw.done(), awaitables):
|
||||
await done_aw
|
||||
|
||||
awaitables = list(filterfalse(lambda aw: aw.done(), awaitables))
|
||||
|
||||
for aw in awaitables:
|
||||
await aw
|
||||
|
||||
|
||||
async def run_utensil(utensil: Utensil, channel: Channel, worktop: Worktop):
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user