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.1.tar.gz (4.7 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.1-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: smem-1.0.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for smem-1.0.1.tar.gz
Algorithm Hash digest
SHA256 829852ab6e7388c99a9aed5e38ada8ee459b8f82acb28f41b65fa84f5c493307
MD5 dab67a9d1961160dd58d0082e1f336cb
BLAKE2b-256 f7cdaa65d7f4bbb092f81c5c82399b2e7b5b2f5d6033bfb38e3e0745b0cfbcc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for smem-1.0.1.tar.gz:

Publisher: python-publish.yml on hlpdev/SMem

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: smem-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for smem-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 12482a71b96e38aefae7bf870fab4ec31bcf990a5218fccfd5d5801ce72e4d95
MD5 d8c955f0613b3fb13d0b3acb1ae08380
BLAKE2b-256 c96b78850b032541bc56ee909a28eb6c309e43f98898aa463434af68f6de8fce

See more details on using hashes here.

Provenance

The following attestation bundles were made for smem-1.0.1-py3-none-any.whl:

Publisher: python-publish.yml on hlpdev/SMem

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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