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.3.tar.gz
.
File metadata
- Download URL: parallel_websocket_server-0.1.3.tar.gz
- Upload date:
- Size: 1.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.2.0-1012-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31deedb89f1b625d24f6f8217758a610a24b97c81a5e32be85befe79f3c9d492 |
|
MD5 | f41212746ee5abf44e83d047dc621bdd |
|
BLAKE2b-256 | c1b16ecb9f38d6c62a0fb74ab0de8405cdb63ecb274fa56b053824d45c32eea2 |
File details
Details for the file parallel_websocket_server-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: parallel_websocket_server-0.1.3-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.11.5 Linux/6.2.0-1012-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f9be892bf5f8235de189436d917cf1d288ff7fb5aab7241539f9269e7a29e2b5 |
|
MD5 | 198498e1100daab106f172dc59bf2aec |
|
BLAKE2b-256 | ed2f23de26718ad3bca1e62c047bd8c76960f9a59c40199dceeee81d10e2f4d8 |