Skip to content

Commit

Permalink
fix example for 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
circuitsacul committed Jun 27, 2023
1 parent dcd3262 commit 8345fa8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion example/client.py
Original file line number Diff line number Diff line change
@@ -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)


Expand Down

0 comments on commit 8345fa8

Please sign in to comment.