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

Websocket client and asyncio.async #645

Closed
no-paj opened this issue Nov 27, 2015 · 2 comments
Closed

Websocket client and asyncio.async #645

no-paj opened this issue Nov 27, 2015 · 2 comments
Labels

Comments

@no-paj
Copy link

no-paj commented Nov 27, 2015

Hi,
I was reading the doc about websocket client :

session = aiohttp.ClientSession()
async with session.ws_connect('http://example.org/websocket') as ws:

    async for msg in ws:
        if msg.tp == aiohttp.MsgType.text:
            if msg.data == 'close cmd':
                await ws.close()
                break
            else:
                ws.send_str(msg.data + '/answer')
        elif msg.tp == aiohttp.MsgType.closed:
            break
        elif msg.tp == aiohttp.MsgType.error:
            break

But it seems that async is deprecated now. How to make this code working with python 3.5 ?

@asvetlov asvetlov added the question StackOverflow label Nov 27, 2015
@asvetlov
Copy link
Member

The snippet is 100% correct and works on Python 3.5+

asyncio.async coroutine is deprecated for sake of async def, async with and async for keywords.

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants