python multiprocessing websocket server
Project description
parallel_websocket_server
run websocket server in parallel (using multiprocessing)
You can run the websocket server as a subprocess while keeping the main process distinct.
You can implement the main process without having to pay attention to the server.
Installation
pip install parallel_websocket_server
How to use
import json
import random
import multiprocessing as mp
from parallel_websocket_server import ParallelWebSocketServer
if __name__ == "__main__":
receive_queue = mp.Queue()
send_queue = mp.Queue()
server = ParallelWebSocketServer(receive_queue, send_queue)
while True:
if not receive_queue.empty():
received_message = receive_queue.get_nowait()
print(received_message)
ran = random.random()
if ran < 0.00001:
send_queue.put(json.dumps({"hoge": 1}))
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for parallel_websocket_server-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6381b9bb27de1c5811707e0eb7dfb5c9e71689aaf4118386f29a5df4326ced05 |
|
MD5 | 6dabb23f1495d34b7c2fe5d22a7c9018 |
|
BLAKE2b-256 | 4bb6d84c56f04a87a691857638710452f86b9e6bc3d6929c9ea2851b91ea8db7 |
Close
Hashes for parallel_websocket_server-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6acf343299547e63a3840c2dc194edcbf3436ca6d673291451ca6f4dbe7fa2e4 |
|
MD5 | eb73271e652b015ac7e135acbfa3a5f4 |
|
BLAKE2b-256 | abfcbe33a6f196fc4af2356478165dba0188fb604aa9b696b23e30f34e965232 |