From 822d38dcf90306d5a693677963bc1795bbbec2a4 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Thu, 19 Aug 2021 14:06:33 -0400 Subject: [PATCH] Tighten --- chat.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/chat.py b/chat.py index 7100c75..485d5c9 100644 --- a/chat.py +++ b/chat.py @@ -42,15 +42,10 @@ def main_facet(turn, root_facet, ds): async def accept_input(): reader = asyncio.StreamReader() - await actor.find_loop().connect_read_pipe( - lambda: asyncio.StreamReaderProtocol(reader), - sys.stdin) - while True: - line = (await reader.readline()).decode('utf-8') - if not line: - actor.Turn.external(f, lambda turn: turn.stop(root_facet)) - break + await actor.find_loop().connect_read_pipe(lambda: asyncio.StreamReaderProtocol(reader), sys.stdin) + while line := (await reader.readline()).decode('utf-8'): actor.Turn.external(f, lambda turn: turn.send(ds, Says(me, line.strip()))) + actor.Turn.external(f, lambda turn: turn.stop(root_facet)) turn.linked_task(accept_input()) def main(turn):