Skip to main content

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

"Buy Me A Coffee"

Examples of usage:

  1. 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
  1. 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


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)

Uploaded Source

Built Distribution

asyncio_guard-1.0.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

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

Hashes for asyncio_guard-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5d5166d36178e165a367da3a7bcdc17666eabed104f1d3cef1533d26f1e0b802
MD5 215cf0b9fb5d012a109571fa326dfe57
BLAKE2b-256 b4fb3b48eeb8f97aa5745fa9d5f0814c3b105cb546fc8f7eb3aced837f2aff42

See more details on using hashes here.

File details

Details for the file asyncio_guard-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for asyncio_guard-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2fedecaad836d0a2450503c037eeb7d20f9cd98da0f10f83bcf4ac6813e9550
MD5 55485aecd616f5929fb87e4c111374e9
BLAKE2b-256 52abb06cb86e0002d95729d78b63c9a4cd67d56b23316504b50dcc07813b8ea8

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page