Skip to main content

SharedMemory encapsulation

Project description

SharedMemory

Encapsulation of the python shared_memory library.

Features

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

Future improvement

  • Adding more tests

Example

Example of execution in two instances of ipython.

Client side

In [1]: from SharedMemory import Client

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

In [3]: C.getStatus()
Out[3]: 'Started'

In [4]: C.getAvailability() # First boolean: Client Availability, Second boolean: Server Availability
Out[4]: (True, 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.updateValue('HW')

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

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

Server side

In [1]: from SharedMemory import Server

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

In [3]: S.getStatus()
Out[3]: 'Connected'

In [4]: S.getAvailability() # First boolean: Server Availability, Second boolean: Client Availability
Out[4]: (True, True)

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

In [6]: S.updateValue("World")

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]: # Closing the server side
    ...: S.stop()

More

PyPI version Python package Upload Python Package Python 3.8 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-0.3.0.dev0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

SharedMemory-0.3.0.dev0-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file SharedMemory-0.3.0.dev0.tar.gz.

File metadata

  • Download URL: SharedMemory-0.3.0.dev0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for SharedMemory-0.3.0.dev0.tar.gz
Algorithm Hash digest
SHA256 c06a9b71b219f07ff5c767ac0e1c91bd10b39cc1329ac3ca1679965b953f762b
MD5 8d009bf5bbc07b629e288ee02dafe46f
BLAKE2b-256 a32a16ea0b27f668727a0b8ed4b9a833043b058ab59b6e465f70450c804269d2

See more details on using hashes here.

File details

Details for the file SharedMemory-0.3.0.dev0-py3-none-any.whl.

File metadata

  • Download URL: SharedMemory-0.3.0.dev0-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6

File hashes

Hashes for SharedMemory-0.3.0.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a6aa916737c64aacb1212582d6f8ea72e57ad577047543096305ca61b21a960
MD5 d5a8e1513f3bfe9faf729418c2e0ed52
BLAKE2b-256 069c2cb8075d48f8975dc3f14c2ae095bb6a9eccf67468db91313b158d9e049b

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