Has anyone fucked Python's Websocket Client? I'd like to ask a few questions.

there are too few documents on the Internet, so let"s ask the first question, Websocket Client of Python, how to subscribe to a specified channel?

I can"t find it all over Google. I see a lot of articles are written:

ws.send (json.dumps ({"event": "subscribe", "channel": "trades"})

I can"t figure it out. This is just a common way to send messages. What kind of subscription is it? A method like ws.subscribe (url) cannot be found at all.


https://websockets.readthedoc...

-sharp!/usr/bin/env python

-sharp WS client example

import asyncio
import websockets

async def hello():
    async with websockets.connect(
            'ws://localhost:8765') as websocket:
        name = input("What's your name? ")

        await websocket.send(name)
        print(f"> {name}")

        greeting = await websocket.recv()
        print(f"< {greeting}")

asyncio.get_event_loop().run_until_complete(hello())

answer according to impression. For reference only.

subscription mechanism, find out that python should have a specific implementation. If you use python, implement it yourself, you need to use more complex communication principles. Such as semaphores.
in addition, it is implemented in combination with cooperative procedures, or process communication.

another solution can be implemented directly with redis or mongodb. It's relatively simple.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e87b23-e77.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e87b23-e77.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?