Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example webterm.py fails, send_str never awaited. #122

Open
ilar opened this issue Aug 9, 2018 · 2 comments
Open

Example webterm.py fails, send_str never awaited. #122

ilar opened this issue Aug 9, 2018 · 2 comments

Comments

@ilar
Copy link

ilar commented Aug 9, 2018

If you try to run webterm.py, it will fail, giving the errors:

webterm.py:86: RuntimeWarning: coroutine 'WebSocketResponse.send_str' was never awaited ws.send_str(terminal.dumps())
webterm.py:90: RuntimeWarning: coroutine 'WebSocketResponse.send_str' was never awaited ws.send_str(terminal.dumps())

This is with python3.5 and 3.6, and aiohttp 3.3.2.

@kyrgyz-nlp
Copy link

This is with python3.5 and 3.6, and aiohttp 3.3.2.

Starting from version 3.0 aiohttp converted send_str into a coroutine. Install aiohttp==2.3.10 and you'll be good to go.
I tried to fix this by applying await before ws.send_str and converting on_master_output into an async function. But in loop.add_reader(p_out, on_master_output) add_reader doesn't allow the callback to be async.
I would be happy to hear suggestions on how to update the example.

@positron96
Copy link

positron96 commented Sep 27, 2022

I've fixed that by changing ws.send_str... in on_master_output to asyncio.ensure_future(ws.send_str(terminal.dumps())).

The more-preferred-now version asyncio.create_task(ws.send_str(terminal.dumps())) should also work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants