Hi
This library is very handy but seems it can't be used with async fns - where it would be very helpful. Simple example:
import asyncio
import time
import codetiming
@codetiming.Timer(name="my_func", initial_text='Started...', text="{name} complete in {:.4f} secs")
def my_func():
time.sleep(5)
print('done')
@codetiming.Timer(name="my_async_func", initial_text='Started...', text="{name} complete in {:.4f} secs")
async def my_async_func():
time.sleep(5)
print('done')
my_func() # timing ok...
loop = asyncio.get_event_loop()
loop.run_until_complete(my_async_func()) # timing 0.0 sec
This gives output:
Started...
done
my_func complete in 5.0052 secs
Started...
my_async_func complete in 0.0000 secs
done
Is there a way to use it to correctly report the actual elapsed time for the async function somehow?
Hi
This library is very handy but seems it can't be used with async fns - where it would be very helpful. Simple example:
This gives output:
Is there a way to use it to correctly report the actual elapsed time for the async function somehow?