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 and dict
  • Management of the availability of shared memory space
  • Overloaded methods for list and dict

Future improvement

  • Mutex
  • Timeout for Mutex
  • Adding nparray support
  • 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", exist=False)

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", exist=True)

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.1.0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

SharedMemory-1.1.0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: SharedMemory-1.1.0.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for SharedMemory-1.1.0.tar.gz
Algorithm Hash digest
SHA256 d69551f1329e988bb949c4778d87f0bd039be9411c0b301120b11ae442b6b01e
MD5 11f46039c7236fa514936b6602285d7b
BLAKE2b-256 680a4c637d3520a59268e93b425f22060c56c854d2eff25679cdf1cddc073f4e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: SharedMemory-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for SharedMemory-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7620ed98e9bd178a9a93b0f728587fbce149643d9f40633704282b846a8f4c54
MD5 5b832612e42e2738509a24b395b2e34d
BLAKE2b-256 97cbbe3a833f958c08a6a02a501b3821d7379a0dd4a6106f337af6c12d19eaf2

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