dipc
Distributed Inter-Process Communication Library implemented in Python and Memcached. server
Using dipc
dipc library has two classes for distributed lock and semaphore, MemcacheLock and MemcacheSemaphore
Both of those clases has a first argument which is a list of memcached servers, name of lock/semaphore, ttl - timeout (in seconds). MemcacheSemaphore class has additional parameter value - which is number of processes that can access critical section.
acquire() method will wait forever until lock will be granted. You can specify argument blocking=False, and then will this methid will return True/False depending on if lock was granted or not.
>>> from dipc import MemcacheLock ... ml = MemcacheLock(["localhost:11211"], "lock", ttl=60) ... ml.acquire() ... # critical section ... ml.release()>>> from dipc import MemcacheSemaphore ... ml = MemcacheSemaphore(["localhost:11211"], "semaphore", value=10, ttl=60) ... ml.acquire() ... # critical section ... ml.release()
There are also decorators available: distributed_lock and distributed_semaphore First argument is a list of hosts, but it also can be a function that returns list of hosts (for those environments that have config file read in a lazy manner)
>>> from dipc.decorators import distributed_lock ... ... @distributed_lock(["localhost:11211"], "lock", ttl=60) ... def foo(): ... # body>>> from dipc.decorators import distributed_semaphore ... ... @distributed_semaphore(["localhost:11211"], "semaphore", value=10, ttl=60) ... def bar(): ... # body
Metadata
Release files for dipc 0.4
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 |
|---|---|---|---|---|
| dipc-0.4.tar.gz | 3.6 kB | Without provenance | Details for dipc-0.4.tar.gz |
Release files / dipc-0.4.tar.gz
| Download URL | dipc-0.4.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0c19a7f3ad99bc33ab1f3496496dadf0859bf32d067b8085311122b8a5702c93
|
|
BLAKE2b-256 checksum How to use checksums |
cb880cc5777d999dd488cec78fce65bc4bfc768bea92b9d6e6cefd687d152213
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for dipc 0.4
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.