WebSocket库
asyncwebsockets的Python项目详细描述
AsyncWebSocket是一个anyio兼容的WebSocket客户端库。 因此,它与curio、trio或asyncio一起工作。
安装
要安装最新的稳定版本:
$ pip install asyncwebsockets
要安装最新的开发版本:
$ pip install git+https://github.com/Fuyukai/asyncwebsockets.git#egg=asyncwebsockets
基本用法
importanyioimportasyncwebsocketsasyncdeftest():asyncwithasyncwebsockets.open_websocket("wss://echo.websocket.org")asws:awaitws.send("test")evt=awaitws.next_event()print(type(evt),getattr(evt,'data',None))anyio.run(test)