async def handle_packet(packet):
xxxxx
async def read_from_websocket(uri):
async with websockets.connect(uri) as websocket:
while True:
packet = await websocket.recv()
await handle_packet(packet)
asyncio.run(read_from_websocket(uri))
【 在 migrant 的大作中提到: 】
: 其实我用来做交易的一个东西,那个函数相当于一个策略,用到不同的品种上,
: websocket接收数据,然后死循环不停计算,如果用进程太占资源了
--
FROM 119.139.197.*