aiorem
A simple asyncio context manager with explicit interface.
Introduction
This library provides a simple context manager for managing resources in an asyncio environment. It’s designed to have an explicit interface, which makes it easy to use both as context manager and as a regular object for custom use cases.
Installing
You can install or upgrade aiorem via
$ pip install aiorem --upgrade
Motivation
When working with asyncio Python libraries, async context managers are a common pattern for managing resources and snippets like
async with some_lib.Client() as client:
...
are often seen in the quickstart. However, there are two use cases, where this pattern is hard to use and an explicit interface for acquiring and releasing resources is desirable.
Nested context managers: When writing a class that manages several resources, acquiring and releasing these resources should each usually be bundled in a single method.
Low level event loop usage: In some advanced cases, it can be desirable to use things like loop.run_until_complete than await-ing a coroutine.
For both cases, one can then either explicitly call Client.__aenter__ and Client.__aexit__ or duplicate whatever logic is used within these methods. Unfortunately, the behavior of Client.__aenter__ and Client.__aexit__ is not always well documented. Moreover, using magic/dunder might be viewed as bad practice, as they are mostly intended to be used by the Python interpreter.
This shortcoming is what aiorem aims to improve. As the Quick Start below shows, subclasses of aiorem.AbstractResourceManager can be used in different ways according to the needs of the use case while the behavior is well documented and explicit. For the case of nested context managers, aiorem provides the AbstractResourceManagerCollection class as a natural extension of AbstractResourceManager.
Quick Start
Here is a simple example of how to use aiorem:
import asyncio
from aiorem import AbstractResourceManager
class ResourceManager(AbstractResourceManager):
async def acquire_resources(self):
print("Resource acquired")
async def release_resources(self):
print("Resource released")
async def context_manager():
async with ResourceManager():
print("Context manager block")
@ResourceManager()
async def decorator():
print("Decorator block")
async def explicit_interface():
rm = ResourceManager()
await rm.acquire_resources()
print("Explicit interface block")
await rm.release_resources()
async def main():
await context_manager()
await decorator()
await explicit_interface()
if __name__ == "__main__":
asyncio.run(main())
For more information on how to use aiorem, please refer to the documentation.
Metadata
Release files for aiorem 0.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 |
|---|---|---|---|---|
| aiorem-0.0.4.tar.gz | 6.8 kB | With provenance | Details for aiorem-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aiorem-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for aiorem-0.0.4-py3-none-any.whl |
Total release size: 13.4 kB
Release files / aiorem-0.0.4.tar.gz
| Download URL | aiorem-0.0.4.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
08d3fc797f72b9b003e43e1792668960379fe47d83bd82491f62cf5aa72e84df
|
|
BLAKE2b-256 checksum How to use checksums |
9fcb1181b0fd4c3d2b6c32af8f4a9ff461d970d106fac7454ff73587e5c9ca6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2025.
Transparency logRelease files / aiorem-0.0.4-py3-none-any.whl
| Download URL | aiorem-0.0.4-py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2fd772a0249b85575039db1d41db9350ebc891f9011f5b8f3d36585793565f83
|
|
BLAKE2b-256 checksum How to use checksums |
295292a5ca50f28a2c96808e8661f41ba117ba7041ec5c17115fe43342447c68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2025.
Transparency logSecurity for aiorem 0.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for aiorem-0.0.4.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2025.
Transparency logA 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.