Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Decorated async functions report 0 time #55

Copy link
Copy link
@rmaunder

Description

@rmaunder
Issue body actions

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?

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.