Skip to main content

A Python library that is used to handle interprocess communication platform independently in Python.

Project description

SMem

The SMem library is used to handle interprocess communication (IPC) platform independently in Python.

Usage

[!NOTE] You must provide a name for the shared memory instance.

The size of the shared memory defaults to 1024

The create flag on the shared memory instance defaults to false, so make sure you ensure that an instance of the shared memory exists!

Creating a shared memory instance:

from smem.smem import SMem

# Create the SMem instance with the "create" flag 
# enabled and a specified "size" of 1024
shared_memory = SMem("my_shared_memory", create=True, size=1024)

Attaching to a shared memory instance:

Useful for reading an existing shared memory instance.

from smem.smem import SMem

# Create the SMem instance with the "size" flag set to 1024
# (the same as when we created it)
shared_memory = SMem("my_shared_memory", size=1024)

Writing to shared memory

Writing to shared memory will overwrite the existing value.

# Assume "shared_memory" contains an active instance of SMem
data = b"This is my data to write!"
shared_memory.write(data)

Reading shared memory

# Assume "shared_memory" contains an active instance of SMem
data = shared_memory.read()

Closing an instance

Closing an instance that created the shared memory file:

# Assume "shared_memory" contains an active instance of SMem
# that created the shared memory file
shared_memory.close()
shared_memory.unlink()

Closing an instance that did not create the shared memory file:

# Assume "shared_memory" contains an active instance of SMem
# that did not create the shared memory file
shared_memory.close()

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

smem-1.0.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

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

smem-1.0.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file smem-1.0.0.tar.gz.

File metadata

  • Download URL: smem-1.0.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.13

File hashes

Hashes for smem-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f01a6f58b76a25758ee78b5930185c27c4089e26c6e66ccecce778113288f197
MD5 72599168a89344eb5c16972eaf37f103
BLAKE2b-256 1bc36a2c3e31e1dbfb7df34cb088f0cbcfb317c90530c9fad991ccb5a223390b

See more details on using hashes here.

File details

Details for the file smem-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: smem-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.13

File hashes

Hashes for smem-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fae9968da667e4afb4719e94d543f2876cd5855d1650eb0f2bf89565d3598c9e
MD5 0260ecc38414de0a90b2046e5e74e1fa
BLAKE2b-256 f103742f1ecf99d095e1bba9a42ebd71daab4cfb0ae691a63aabb43af8023ee7

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