Skip to main content

Awesome pyrtshm created by pappacena

Project description


pyrtshm

codecov CI

pyrtshm is a real-time distributed shared memory implemented in python over UDP protocol using protobuf.

It is intended to be used as a dict that mirrors its keys and values across distributed nodes in environments that can tolerate packet losses, but need real time updates. For example, games backend, live stream of stock prices, machine discovery and monitoring, etc.

To give a simple example, think of 2 hosts running your project, node-1 and node-2. In node-1 you have:

mem = SharedMemory(listen=('0.0.0.0', 3333), forward_nodes=[('node-2', 3333)])

In node-2, you have:

mem = SharedMemory(listen=('0.0.0.0', 3333), forward_nodes=[('node-1', 3333)])

Now, if you set any key in one of the nodes like this:

mem["my-key"] = 1

In almost real time, with high thoughput, mem["my-key"] will have value 1 in the other node. You can add as many nodes as needed in the forward_nodes list.

Install it from PyPI

pip install pyrtshm

Usage

from pyrtshm import SharedMemory

# Each node initializes itself by indicating its own port, and the 
# host & sport of the other nodes (the "forward nodes").
other_nodes = [('host1', 3333), ('host2', 3333), ('host3', 3333)]
mem = SharedMemory(listen=('0.0.0.0', 3333), forward_nodes=other_nodes)

# Set a key, making it available to other nodes.
mem["host1/cpu"] = 75.1

# Get a key set by another node.
avg_cpu = mem["host1/cpu"] + mem["host2/cpu"]

# Deletes a key locally and to the other nodes
del mem["host0/cpu"]

Development

Read the CONTRIBUTING.md file.

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

pyrtshm-0.0.1.tar.gz (15.2 kB view details)

Uploaded Source

File details

Details for the file pyrtshm-0.0.1.tar.gz.

File metadata

  • Download URL: pyrtshm-0.0.1.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.5

File hashes

Hashes for pyrtshm-0.0.1.tar.gz
Algorithm Hash digest
SHA256 4a9e81ddaaa76daf3de5ff6684005ca3ca7b59cf9f67707b1cc61468c1f41e80
MD5 324a088caf1d0d86ff2c717d3114e357
BLAKE2b-256 8d4d6523c0ef98b2940c300dd9eee9ed1e057f64d807e9702de33ec48d982e71

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