aiodec
Decorators for asyncio
astopwatch
The astopwatch decorator is used in the following way:
from aiodec import astopwatch
@astopwatch
async def blah(x, y):
return x + y
What does it do? This simple decorator will emit logs with the following message:
INFO:aiodec:Time taken: 0.0003 seconds
Not terribly special. Yet. You can also customize the log message:
from aiodec import astopwatch
@astopwatch(message_template='Time cost was $time_ sec', fmt='%.1g')
async def blah(x, y):
return x + y
This outputs log messages with the following message:
INFO:aiodec:Time cost was 3e-4 sec
Two things: first, the template parameter used for the time cost is called $time_; second, you can customize the formatting of the seconds value. However, it can also do something a lot more interesting: it can include parameters from the wrapped function in the message:
from aiodec import astopwatch
@astopwatch(message_template='x=$x y=$y | $time_ seconds')
async def blah(x, y=2):
return x + y
loop.run_until_complete(blah(1))
This outputs log messages with the following message:
INFO:aiodec:x=1 y=2 | 0.0003 seconds
Magic! Note that positional args and keyword args and default values are all handled correctly.
As you saw earlier, in addition to the function parameters, the special $time_ parameter will also be available. The other extra fields are:
$name_, which contains the __name__ of the wrapped function, and
$qualname_, which contains the __qualname__ of the wrapped function.
These three template parameters have a trailing underscore, to avoid collisions with any parameter names.
Metadata
Release files for aiodec 2018.10.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 | |
|---|---|---|---|---|
| aiodec-2018.10.1.tar.gz | 8.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiodec-2018.10.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 24.4 kB
Release files / aiodec-2018.10.1.tar.gz
| Download URL | aiodec-2018.10.1.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
33f098a78aaa7afda421f250d69f75258828e8c6694a7434082b93da60e3ffb8
|
|
BLAKE2b-256 checksum How to use checksums |
5224069f91cbff71eb5742698afb484b363cdf00e56923d8964a4051bd1985a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.20.0
|
Release files / aiodec-2018.10.1-py2.py3-none-any.whl
| Download URL | aiodec-2018.10.1-py2.py3-none-any.whl |
|---|---|
| Size | 16.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
422a34ca9dfc7de6642e1b67ffd9f44ad60a1500d7d9991afe3bc0405e4ab8e3
|
|
BLAKE2b-256 checksum How to use checksums |
e77d85c0f82552bc49c1976ded0edf49afa77043e6d3bf07b5eb4d27ad186770
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.20.0
|
Security for aiodec 2018.10.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.