Guard that provide exclusive access to an object
Project description
Guard that provide exclusive access to an object
Python 3.7 or higher.
Install: pip install asyncio-guard
Examples of usage:
- Set a value, get exclusive access to it, set another value
guard = Guard(obj=1)
async with guard as obj:
assert obj == 1
await guard.set(2)
async with guard as obj:
assert obj == 2
- Update a value by using update function.
This update function will be used, if no value was set up.
guard = Guard(obj=1, update_func=lambda: return 2)
async with guard as obj:
assert obj == 1
await guard.update_func()
async with guard as obj:
assert obj == 2
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
asyncio_guard-1.0.0.tar.gz
(3.0 kB
view details)
Built Distribution
File details
Details for the file asyncio_guard-1.0.0.tar.gz
.
File metadata
- Download URL: asyncio_guard-1.0.0.tar.gz
- Upload date:
- Size: 3.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d5166d36178e165a367da3a7bcdc17666eabed104f1d3cef1533d26f1e0b802 |
|
MD5 | 215cf0b9fb5d012a109571fa326dfe57 |
|
BLAKE2b-256 | b4fb3b48eeb8f97aa5745fa9d5f0814c3b105cb546fc8f7eb3aced837f2aff42 |
File details
Details for the file asyncio_guard-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: asyncio_guard-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2fedecaad836d0a2450503c037eeb7d20f9cd98da0f10f83bcf4ac6813e9550 |
|
MD5 | 55485aecd616f5929fb87e4c111374e9 |
|
BLAKE2b-256 | 52abb06cb86e0002d95729d78b63c9a4cd67d56b23316504b50dcc07813b8ea8 |