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 (basic)
- Methods to manage all defined shared space
- Space Memory configurable
- Semaphore
Installation
$> pip install SharedMemory
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
Project details
Release history Release notifications | RSS feed
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.4.1.tar.gz
(21.0 kB
view hashes)
Built Distribution
Close
Hashes for SharedMemory-1.4.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d75db7d716c174880d4f350ae468d2887ba6346e6ec2885b3aa4e1516c38f4a |
|
MD5 | d883e5162b49744147c3821a0bbc3e75 |
|
BLAKE2b-256 | f87b1aa7f98ff25cd45c2be25303ee793db949e47044d5ef99486ca09ecdd7bf |