Skip to main content

python multiprocessing websocket server

Project description

parallel_websocket_server

run websocket server in parallel (using multiprocessing)

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

parallel_websocket_server-0.1.1.tar.gz (1.7 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file parallel_websocket_server-0.1.1.tar.gz.

File metadata

  • Download URL: parallel_websocket_server-0.1.1.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

Hashes for parallel_websocket_server-0.1.1.tar.gz
Algorithm Hash digest
SHA256 04013c7da5b35acb1466044a1e3060ed5b6d8f7c7724dd9bc127aaa4011f3e38
MD5 177b4b4e9ff32605d778544d5bc5af14
BLAKE2b-256 5c524da327263f64a8c17a7e4a4eb5a611f7d5effcf8fa08f4516b36e5953cd3

See more details on using hashes here.

File details

Details for the file parallel_websocket_server-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for parallel_websocket_server-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6387b02d295639078b656b1d82cac48894773a97a74667c99b8e7d690e051723
MD5 6e24675532d7c697da3f1aa0f28cb893
BLAKE2b-256 531f2809f6574cbf8f64eb87706a8a9f9132375c337da1b2125cc718137463db

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page