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 hashes)
Built Distribution
Close
Hashes for asyncio_guard-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2fedecaad836d0a2450503c037eeb7d20f9cd98da0f10f83bcf4ac6813e9550 |
|
MD5 | 55485aecd616f5929fb87e4c111374e9 |
|
BLAKE2b-256 | 52abb06cb86e0002d95729d78b63c9a4cd67d56b23316504b50dcc07813b8ea8 |