Skip to main content

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

parallel_websocket_server-0.1.3.tar.gz (1.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parallel_websocket_server-0.1.3-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

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

Hashes for parallel_websocket_server-0.1.3.tar.gz
Algorithm Hash digest
SHA256 31deedb89f1b625d24f6f8217758a610a24b97c81a5e32be85befe79f3c9d492
MD5 f41212746ee5abf44e83d047dc621bdd
BLAKE2b-256 c1b16ecb9f38d6c62a0fb74ab0de8405cdb63ecb274fa56b053824d45c32eea2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for parallel_websocket_server-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f9be892bf5f8235de189436d917cf1d288ff7fb5aab7241539f9269e7a29e2b5
MD5 198498e1100daab106f172dc59bf2aec
BLAKE2b-256 ed2f23de26718ad3bca1e62c047bd8c76960f9a59c40199dceeee81d10e2f4d8

See more details on using hashes here.

Supported by

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