This module helps to solve the following problem:
You have an async program. It does lots of things in parallel.
You don't really know what's happening. Then you get a deadlock,
or a cancellation whose initial trigger is masked by another error
or an unprotected async call within a finally: block.
You now have no idea what's happening, and low-level instrumentation of your code causes the error to get lost in the noise.
Here's how logcontext can help.
First, wrap your main code::
from logcontext import main_context
def main():
with main_context():
... # whatever your program does
Then you wrap each possibly-interesting block, nursery, async context, … with
from logcontext import context_of
...
async def code_of_interest(arg):
with context_of("interesting: %s", arg) as ctx:
... # start some subtask
# display what my subcontexts are doing, if anything
ctx.log_tree()
Text and positional arguments will be passed to logging.log.
Reporting on the current state of your code is then as easy as::
from logcontext import log_backtrace, log_tree
...
log_tree() # reports the whole program's context tree
log_backtrace() # reports the contexts leading to the current code
Both context_of and log_tree accept a log level. This way you can
selectively attach higher log levels to possibly-interesting code.
"Uninteresting" subtrees are skipped.
"""
from ._main import main_context, context_of, log_backtrace, log_tree
Metadata
Release files for logcontext 0.1.1
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 |
|---|---|---|---|---|
| logcontext-0.1.1.tar.gz | 4.0 kB | Without provenance | Details for logcontext-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| logcontext-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for logcontext-0.1.1-py3-none-any.whl |
Total release size: 7.9 kB
Release files / logcontext-0.1.1.tar.gz
| Download URL | logcontext-0.1.1.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e480277f542e058c31192ef1d1405f6cb3ce42ab944ebe37b640d359d0b376a6
|
|
BLAKE2b-256 checksum How to use checksums |
79ef77dc69541a6e8c252dc2fde062589577db660c50d784cf6bf6faf621dbf7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.8.2 requests/2.25.1 setuptools/65.3.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.10.7
|
Release files / logcontext-0.1.1-py3-none-any.whl
| Download URL | logcontext-0.1.1-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d527838a09092668e80c242bd31e20785d21e1e498a9094166c01b4ed8c0d6e9
|
|
BLAKE2b-256 checksum How to use checksums |
918840e57c0fdde654da660e9ac291d54f30ed5d86b5e7ab7abffe54a442cd12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.8.2 requests/2.25.1 setuptools/65.3.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.10.7
|
Security for logcontext 0.1.1
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.