From 8345fa831e45b989e29d85441a8b5d3751db5ffa Mon Sep 17 00:00:00 2001 From: CircuitSacul Date: Tue, 27 Jun 2023 15:12:39 -0400 Subject: [PATCH] fix example for 3.8 --- example/client.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/example/client.py b/example/client.py index 600a9ae..89e23d4 100644 --- a/example/client.py +++ b/example/client.py @@ -1,13 +1,22 @@ import asyncio +import sys from example.events import Message from socketapp import Client +if sys.version_info < (3, 9, 0): + from concurrent.futures import ThreadPoolExecutor + async def send(client: Client) -> None: await client.wait_until_ready() while True: - inp = await asyncio.to_thread(input) + if sys.version_info < (3, 9, 0): + with ThreadPoolExecutor(1, "AsyncInput") as executor: + inp = await asyncio.get_event_loop().run_in_executor(executor, input) + else: + inp = await asyncio.to_thread(input) + await client.send(Message(data=inp), client.clients)