Skip to content

Commit

Permalink
actually fix it this time
Browse files Browse the repository at this point in the history
  • Loading branch information
circuitsacul committed Jun 27, 2023
1 parent 8345fa8 commit 660e00c
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions example/client.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import asyncio
import sys
from concurrent.futures import ThreadPoolExecutor

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:
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)
with ThreadPoolExecutor(1, "AsyncInput") as executor:
inp = await asyncio.get_event_loop().run_in_executor(executor, input)

# in python 3.9+, you can do this instead:
# inp = await asyncio.to_thread(input)

await client.send(Message(data=inp), client.clients)

Expand Down

0 comments on commit 660e00c

Please sign in to comment.