# 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
```console
$> pip install SharedMemory
```
### Example
Example of execution in two instances of ipython.
#### Client side
```python
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
```python
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
[](https://badge.fury.io/py/SharedMemory)


[](https://www.python.org/downloads/release/python-380/)
[](http://www.gnu.org/licenses/gpl-3.0)
Raw data
{
"_id": null,
"home_page": "https://github.com/Zentetsu/SharedMemory",
"name": "SharedMemory",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "Zentetsu",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/13/9a/043b53b24b5992f03ff45c910e8817353a10987cfd78ad92aba7e2c4dc45/sharedmemory-1.4.2.tar.gz",
"platform": null,
"description": "# SharedMemory\n\nPython shared memory library based an posix-ipc.\n\n### Features\n* Shared type:\n * Basic type (int, float, bool, str)\n * list, tuple, dict and nparray\n* Management of the availability of shared memory space\n* Overloaded methods for list and dict (basic)\n* Methods to manage all defined shared space\n* Space Memory configurable\n* Semaphore\n\n### Installation\n```console\n$> pip install SharedMemory\n```\n\n### Example\nExample of execution in two instances of ipython.\n\n#### Client side\n```python\nIn [1]: from SharedMemory import SharedMemory\n\nIn [2]: # Creating client instance with a shared space named 'shared_space' with a size of 10\n ...: C = SharedMemory(name=\"shared_space\", value=\"Hello\", client=True)\n\nIn [4]: C.getAvailability()\nOut[4]: True\n\nIn [5]: C.getValue()\nOut[5]: 'Hello'\n\nIn [6]: # Waiting for Server to update shared data\n\nIn [7]: C.getValue()\nOut[7]: 'World'\n\nIn [8]: C.setValue('HW')\nOut[8]: True\n\nIn [9]: C.getValue()\nOut[9]: 'HW'\n\nIn [10]: # Closing the client side\n ...: C.close()\n\nIn [11]: C.getAvailability()\nOut[11]: False\n```\n#### Server side\n```python\nIn [1]: from SharedMemory import SharedMemory\n\nIn [2]: # Creating server instance access to the shared named 'shared_space'\n ...: S = SharedMemory(name=\"shared_space\", client=False)\n\nIn [4]: S.getAvailability()\nOut[4]: True\n\nIn [5]: S.getValue()\nOut[5]: 'Hello'\n\nIn [6]: S.setValue(\"World\")\nOut[6]: True\n\nIn [7]: S.getValue()\nOut[7]: 'Hello'\n\nIn [8]: # Waiting for Client to update shared data\n\nIn [9]: S.getValue()\nOut[9]: 'HW'\n\nIn [10]: # Waiting Client to close the shared space\n\nIn [11]: S.getAvailability()\nOut[11]: False\n\n\nIn [12]: # Closing the server side\n ...: S.close()\nINFO: Client already stopped.\n```\n\n\n\n### More\n[](https://badge.fury.io/py/SharedMemory)\n\n\n[](https://www.python.org/downloads/release/python-380/)\n[](http://www.gnu.org/licenses/gpl-3.0)\n",
"bugtrack_url": null,
"license": "GPLv3",
"summary": "SharedMemory",
"version": "1.4.2",
"project_urls": {
"Homepage": "https://github.com/Zentetsu/SharedMemory"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b6178edb6cea4907fc99c254336d99af2a95170f06129855feb9bd20476e2a86",
"md5": "a9ca116b6c08f67b8e5fed6ff99462cb",
"sha256": "41b8b9dc0a3f15dfb106343ae936810db75131213268fe98484ae13d431e1c87"
},
"downloads": -1,
"filename": "SharedMemory-1.4.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a9ca116b6c08f67b8e5fed6ff99462cb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 22161,
"upload_time": "2024-07-03T05:32:20",
"upload_time_iso_8601": "2024-07-03T05:32:20.675521Z",
"url": "https://files.pythonhosted.org/packages/b6/17/8edb6cea4907fc99c254336d99af2a95170f06129855feb9bd20476e2a86/SharedMemory-1.4.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "139a043b53b24b5992f03ff45c910e8817353a10987cfd78ad92aba7e2c4dc45",
"md5": "5548d61260207299587358f120d7cfee",
"sha256": "38b3698603977d49a3d9c00ce390b80decb98bd4b6537d566576d0df88ed7007"
},
"downloads": -1,
"filename": "sharedmemory-1.4.2.tar.gz",
"has_sig": false,
"md5_digest": "5548d61260207299587358f120d7cfee",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 22758,
"upload_time": "2024-07-03T05:32:22",
"upload_time_iso_8601": "2024-07-03T05:32:22.147196Z",
"url": "https://files.pythonhosted.org/packages/13/9a/043b53b24b5992f03ff45c910e8817353a10987cfd78ad92aba7e2c4dc45/sharedmemory-1.4.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-03 05:32:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Zentetsu",
"github_project": "SharedMemory",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "sharedmemory"
}