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
File details
Details for the file parallel_websocket_server-0.1.2.tar.gz
.
File metadata
- Download URL: parallel_websocket_server-0.1.2.tar.gz
- Upload date:
- Size: 1.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.8.13 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6381b9bb27de1c5811707e0eb7dfb5c9e71689aaf4118386f29a5df4326ced05 |
|
MD5 | 6dabb23f1495d34b7c2fe5d22a7c9018 |
|
BLAKE2b-256 | 4bb6d84c56f04a87a691857638710452f86b9e6bc3d6929c9ea2851b91ea8db7 |
File details
Details for the file parallel_websocket_server-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: parallel_websocket_server-0.1.2-py3-none-any.whl
- Upload date:
- Size: 2.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.8.13 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6acf343299547e63a3840c2dc194edcbf3436ca6d673291451ca6f4dbe7fa2e4 |
|
MD5 | eb73271e652b015ac7e135acbfa3a5f4 |
|
BLAKE2b-256 | abfcbe33a6f196fc4af2356478165dba0188fb604aa9b696b23e30f34e965232 |