Skip to main content

SharedMemory

Project description

SharedMemory

Python shared memory library based an posix-ipc.

Features

  • Shared type:
    • Basic type (int, float, bool, str)
    • list, tuple, dict and nparray
  • Management of the availability of shared memory space
  • Overloaded methods for list and dict
  • Semaphore

Future improvement

  • Timeout for Semaphore
  • Adding more tests

Example

Example of execution in two instances of ipython.

Client side

In [1]: from SharedMemory import SharedMemory

In [2]: # Creating client instance with a shared space named 'shared_space' with a size of 10
   ...: C = SharedMemory(name="shared_space", value="Hello", client=True)

In [4]: C.getAvailability()
Out[4]: True

In [5]: C.getValue()
Out[5]: 'Hello'

In [6]: # Waiting for Server to update shared data

In [7]: C.getValue()
Out[7]: 'World'

In [8]: C.setValue('HW')
Out[8]: True

In [9]: C.getValue()
Out[9]: 'HW'

In [10]: # Closing the client side
    ...: C.close()

In [11]: C.getAvailability()
Out[11]: False

Server side

In [1]: from SharedMemory import SharedMemory

In [2]: # Creating server instance access to the shared named 'shared_space'
   ...: S = SharedMemory(name="shared_space", client=False)

In [4]: S.getAvailability()
Out[4]: True

In [5]: S.getValue()
Out[5]: 'Hello'

In [6]: S.setValue("World")
Out[6]: True

In [7]: S.getValue()
Out[7]: 'Hello'

In [8]: # Waiting for Client to update shared data

In [9]: S.getValue()
Out[9]: 'HW'

In [10]: # Waiting Client to close the shared space

In [11]: S.getAvailability()
Out[11]: False


In [12]: # Closing the server side
    ...: S.close()
INFO: Client already stopped.

More

PyPI version Python package Upload Python Package Python License: GPL v3

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

SharedMemory-1.3.2.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

SharedMemory-1.3.2-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file SharedMemory-1.3.2.tar.gz.

File metadata

  • Download URL: SharedMemory-1.3.2.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for SharedMemory-1.3.2.tar.gz
Algorithm Hash digest
SHA256 95e055f8d68b976207695c637c7c4166f613fd70892cb77d0949b081785f2212
MD5 ee16e73e02f11848193c124772bcd089
BLAKE2b-256 27a1598d9e5a525c403cd3854555ecf45904de12ca8a4f2f069d15ae1cbb281a

See more details on using hashes here.

File details

Details for the file SharedMemory-1.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for SharedMemory-1.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a728929e463361a7ae628220f6b47adea1ca8ae3d690bb8798db32c01a1d9ca3
MD5 0f5f6764ac11d41de88b6e83858ff771
BLAKE2b-256 13c2fccfcd9f1f3b5f26e13811dbf98886abf5addd4102562e4d7478e2712099

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