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