Skip to main content

All Questions

0 votes
0 answers
27 views

Backend WebSocket server causes client page to refresh unexpectedly

I'm working on a radio web project that streams radio stations through a web interface. The backend, written in Python, uses WebSockets to receive messages from the client and returns the currently ...
Vanilla1002's user avatar
0 votes
1 answer
432 views

How to use websockets.broadcast() in while True loop

In this function, I want to get video frames and predict them, then broadcast predicted result to all subscribers, but when I run this function, clients can't receive result. Because code don't return ...
Ian Shih's user avatar
0 votes
0 answers
61 views

How to add new thread for every new client in python websockets?

import asyncio import websockets import threading async def server_handle(websocket,path): print("Server is waiting!!!!") while True: msg = await websocket.recv() ...
vishnu_data_science's user avatar
0 votes
1 answer
177 views

How do you exit this websocket and eventloop example?

!/usr/bin/env python import asyncio import websockets buttcount=0 async def hello(websocket, path): global buttcount name = await websocket.recv() print(name) if name=="butt&...
zenner55's user avatar
1 vote
2 answers
1k views

Save Received Candle Stick Message from KuCoin Websocket to variable and then to database

I have this Code to connect to the KuCoin web socket and receive the candle stick data. My question is: How can I save the message to a variable (maybe in a another script)? I want to use this data ...
Max Power's user avatar
0 votes
1 answer
1k views

Use the same websocket connection in multiple asynchronous loops (Python)

I am running two loops asynchronously, and want both to have access to the same websocket connection. One function periodic_fetch() fetches some data periodically (every 60 seconds) and sends a ...
HaakonFlaar's user avatar
2 votes
2 answers
2k views

How to use asyncio.wait_for to run_until_complete to synchronously call async method in Python

To allow timeouts receiving data via Python websocket, the FAQ: How do I set a timeout on recv()? recommends using asynchronously receive data: await asyncio.wait_for(websocket.recv(), timeout=10) ...
Fruchtzwerg's user avatar
  • 11.4k
0 votes
1 answer
766 views

How do you extract data from multiple websocket streams to use in a formula?

The following code is attempting to obtain stream messages from "connections" set. I'm trying to figure out how to extract two float values--one from each stream--to calculate a quotient. ...
Query13's user avatar
  • 11
1 vote
1 answer
957 views

With asyncio in Python 3 code, how can I (re)start/stop non-blocking websocket IO recurrently?

In my live phone speech recognition project Python's asyncio and websockets modules are used basically to enable data exchange between client and server in asynchronous mode. The audio stream which to ...
Haskell bit's user avatar
4 votes
2 answers
4k views

Asyncio: Fastapi with aio-pika, consumer ignores Await

I am trying to hook my websocket endpoint with rabbitmq (aio-pika). Goal is to have listener in that endpoint and on any new message from queue pass the message to browser client over websockets. I ...
Martin's user avatar
  • 3,385
1 vote
0 answers
923 views

How to stream information using websockets in python?

I am teaching myself websockets and wrote this code import asyncio import websockets async def stream_msgs(uri,msg): async with websockets.connect(uri) as websocket: await websocket.send(...
Eka's user avatar
  • 15k
1 vote
1 answer
1k views

Bidirectional communiation with websockets in Quart

I want to be able to use a WebSocket in Quart to receive any messages that are sent, and send any messages that I may need to send. There's no guarantee that messages will alternate between sending ...
jarhill0's user avatar
  • 1,629
7 votes
1 answer
13k views

"got Future <Future pending> attached to a different loop" error while using websocket.send(msg) in a while

I'm using websocket to send and receive messages in python. I've used "websocket.send(msg)" to send messages in these forms: await ws.send(message) and asyncio.run(ws.send(message)) inside a while ...
sina ranjkeshzadeh's user avatar
4 votes
2 answers
14k views

Python multiprocessing with async functions

I built a websocket server, a simplified version of it is shown below: import websockets, subprocess, asyncio, json, re, os, sys from multiprocessing import Process def docker_command(command_words):...
Erel Segal-Halevi's user avatar
0 votes
1 answer
656 views

Error when trying to connect to too many websockets

so my code attempts to simultaneously send 300 GET requests and then connect to 300 websockets. It works with 3+ websockets/GET requests but once it gets in the high numbers it outputs an error. Also ...
Matthieu Gavaudan's user avatar

15 30 50 per page