All Questions
13 questions
0
votes
2
answers
299
views
Close Python Websocket server from another thread
I have a websocket server class that has a stop() method that is called when Control+C is pressed in console (so I guess it is accessed from another thread).
How can I safely stop the server (and ...
6
votes
3
answers
1k
views
python: proper way to run an async routine in a pytest fixture?
The test below passes, but I have doubts that I am using asyncio correctly:
The code mixes asyncio and threading
The test is passing but never exits (probably because the "loop....
1
vote
0
answers
81
views
How to make a python multi-threading scraper as a websocket server
I currently have a python multi-threading scraper that looks like following, how can I turn this into a websocket server so that it can push message once the scraper found some new data? Most ...
2
votes
1
answer
1k
views
Websocket running in asyncio loop inside a thread disconnects immediately
I'm developing an application that uses multiple threads for various communication channels. One of them is websocket for which I'm using asyncio loop to run:
class Rotator():
def __init__(self):
...
1
vote
0
answers
233
views
Pass websocket connection to thread
I'm trying to add some functionality to a project which accepts TCP socket connections, to also accept WebSocket connections, but I'm not sure how to best integrate asyncio and threading.
How can I ...
0
votes
1
answer
171
views
How to combine a dynamic amount (150-200) of async functions for calculation purposes
Currently working on a project that uses Binance Websockets to fetch data of the coin prices and makes calculations with the data.
The number of coins that I calculate is dynamic (varies from 150 to ~...
1
vote
1
answer
2k
views
How to return values from an asynchronous function that is executed in a thread in python?
I am new to asynchronous functions and threads, and I am trying to return a series of values obtained from a Web socket to pass to another thread where synchronous code is executing. In the code, I ...
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)
...
-1
votes
1
answer
309
views
Running Python WebSocket While Concurrently Checking Other Unrelated Information with a Function Call Every Minute
I have a WebSocket I run generally as follows:
import websocket
def on_message(ws, message):
...
ws = websocket.WebSocketApp(socket, on_open=on_open, on_message=on_message,
...
2
votes
1
answer
570
views
How to start websocket server in thread using python?
I want to start websocket server in separate thread. I have tried to implement as below but
getting Runtime error as it says attached to different loop
Code:
#!/usr/bin/env python
# WS server example
...
4
votes
0
answers
957
views
How to connect to multiple channels using websocket multiprocessing?
I wrote a script allowing to collect data through different websockets channels but I can't manage to listen to multiple channel at once with this script. I would like to find a solution such as "...
1
vote
2
answers
1k
views
Python tensorflow: asyncio or threading
I am implementing a server for recognizing objects in photos using tensorflow-gpu in "semi-real" time. It will listen for new photos on a websocket connection, then enqueue it into a list for the ...
0
votes
2
answers
2k
views
push with python + asyncio + websockets = missing messages
I'm trying to create a websocket server on which a single client will push its messages (I know this is not the usual way to use websocket but this part is not my choice). To this end, I'm using ...