shmarray
NOTE: If you are using Python 3.8, please turn to multiprocessing.shared_memory instead.
shmarray is a shared numpy-array implementation utilizing multiprocessing.sharedctypes. It is a quite useful small library created of David Baddeley. I found it at https://github.com/lucastheis/parallel/blob/master/shmarray.py
Despite its usefulness, it not only does not come with a pip-installable package, but also contains disrepaired bugs.
This repo is created as a remedy.
Installation
pip install shmarray
Usage
test.py
from multiprocessing import Process
import time
import shmarray
def worker(data):
while True:
data += 1
time.sleep(1)
def monitor(data):
while True:
print(data)
time.sleep(0.5)
data = shmarray.zeros(10)
procs = [
Process(target=worker, args=(data, )),
Process(target=monitor, args=(data, )),
]
for p in procs:
p.start()
for p in procs:
p.join()
Result:
$ python3 test.py
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[2. 2. 2. 2. 2. 2. 2. 2. 2. 2.]
[2. 2. 2. 2. 2. 2. 2. 2. 2. 2.]
[3. 3. 3. 3. 3. 3. 3. 3. 3. 3.]
[3. 3. 3. 3. 3. 3. 3. 3. 3. 3.]
[4. 4. 4. 4. 4. 4. 4. 4. 4. 4.]
[4. 4. 4. 4. 4. 4. 4. 4. 4. 4.]
[5. 5. 5. 5. 5. 5. 5. 5. 5. 5.]
[5. 5. 5. 5. 5. 5. 5. 5. 5. 5.]
[6. 6. 6. 6. 6. 6. 6. 6. 6. 6.]
[6. 6. 6. 6. 6. 6. 6. 6. 6. 6.]
...
Under the hood
The code in shmarray.py is mostly the same as the original, I've only done a few things:
- fix a bug that did not pass
dtypeargument to downstream calls - fix python version compatibility bugs
- reformat the code using black
Metadata
Release files for shmarray 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| shmarray-0.0.3.tar.gz | 4.3 kB | Without provenance | Details for shmarray-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| shmarray-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for shmarray-0.0.3-py3-none-any.whl |
Total release size: 9.6 kB
Release files / shmarray-0.0.3.tar.gz
| Download URL | shmarray-0.0.3.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a9810682d778a6cb051a0e3efa0076dab55c3d7dc1e3cfb7c0712cf36f19d093
|
|
BLAKE2b-256 checksum How to use checksums |
8f3fd1c9152723d257e374aa8471457b854c931230f7fee33bbc3797cfda70df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.7.4
|
Release files / shmarray-0.0.3-py3-none-any.whl
| Download URL | shmarray-0.0.3-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
17f22c295a44f76360437435efaa0828c158cad288c7268c51507fd4870f7919
|
|
BLAKE2b-256 checksum How to use checksums |
662deccccb50515acaf2c0ae840dcc1776184fe6b1319b2c5c57535b99dd6c9d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.7.4
|
Security for shmarray 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.