Tighten
This commit is contained in:
parent
1f7832a358
commit
822d38dcf9
11
chat.py
11
chat.py
|
@ -42,15 +42,10 @@ def main_facet(turn, root_facet, ds):
|
||||||
|
|
||||||
async def accept_input():
|
async def accept_input():
|
||||||
reader = asyncio.StreamReader()
|
reader = asyncio.StreamReader()
|
||||||
await actor.find_loop().connect_read_pipe(
|
await actor.find_loop().connect_read_pipe(lambda: asyncio.StreamReaderProtocol(reader), sys.stdin)
|
||||||
lambda: asyncio.StreamReaderProtocol(reader),
|
while line := (await reader.readline()).decode('utf-8'):
|
||||||
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
|
|
||||||
actor.Turn.external(f, lambda turn: turn.send(ds, Says(me, line.strip())))
|
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())
|
turn.linked_task(accept_input())
|
||||||
|
|
||||||
def main(turn):
|
def main(turn):
|
||||||
|
|
Loading…
Reference in New Issue