Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python.announce > #2572 > unrolled thread
| Started by | Michele Simionato <michele.simionato@gmail.com> |
|---|---|
| First post | 2017-07-15 06:33 -0700 |
| Last post | 2017-07-15 06:33 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python.announce
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
decorator 4.1 is out Michele Simionato <michele.simionato@gmail.com> - 2017-07-15 06:33 -0700
| From | Michele Simionato <michele.simionato@gmail.com> |
|---|---|
| Date | 2017-07-15 06:33 -0700 |
| Subject | decorator 4.1 is out |
| Message-ID | <mailman.115.1500294005.29743.python-announce-list@python.org> |
Dear all,
a new release of the decorator module is out. For the first time we support decorating Python 3.5 coroutines. For instance, this is an example of how to implement a tracing decorator called log_start_stop that you can use for debugging:
import time
import logging
from asyncio import get_event_loop, sleep, wait
from decorator import decorator
@decorator
async def log_start_stop(coro, *args, **kwargs):
logging.info('Starting %s%s', coro.__name__, args)
t0 = time.time()
await coro(*args, **kwargs)
dt = time.time() - t0
logging.info('Ending %s%s after %d seconds', coro.__name__, args, dt)
@log_start_stop
async def make_task(n):
for i in range(n):
await sleep(1)
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
tasks = [make_task(3), make_task(2), make_task(1)]
get_event_loop().run_until_complete(wait(tasks))
You will get an output like this:
INFO:root:Starting make_task(1,)
INFO:root:Starting make_task(3,)
INFO:root:Starting make_task(2,)
INFO:root:Ending make_task(1,) after 1 seconds
INFO:root:Ending make_task(2,) after 2 seconds
INFO:root:Ending make_task(3,) after 3 seconds
Also, for the first time the documentation is hosted on readthedocs.org.
Here are the relevant links:
Download: https://pypi.python.org/pypi/decorator/4.1.1
Project: https://github.com/micheles/decorator/
Docs: http://decorator.readthedocs.io/en/latest/index.html
Back to top | Article view | comp.lang.python.announce
csiph-web