Skip to content

Commit

Permalink
MultiServer: exit console task when console thread dies (ArchipelagoM…
Browse files Browse the repository at this point in the history
  • Loading branch information
black-sliver authored Aug 4, 2023
1 parent 6864f28 commit eb50e07
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion MultiServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2118,13 +2118,15 @@ def attrtype(input_text: str):
async def console(ctx: Context):
import sys
queue = asyncio.Queue()
Utils.stream_input(sys.stdin, queue)
worker = Utils.stream_input(sys.stdin, queue)
while not ctx.exit_event.is_set():
try:
# I don't get why this while loop is needed. Works fine without it on clients,
# but the queue.get() for server never fulfills if the queue is empty when entering the await.
while queue.qsize() == 0:
await asyncio.sleep(0.05)
if not worker.is_alive():
return
input_text = await queue.get()
queue.task_done()
ctx.commandprocessor(input_text)
Expand Down

0 comments on commit eb50e07

Please sign in to comment.