Title: Decorated async functions report 0 time · Issue #55 · realpython/codetiming · GitHub
Open Graph Title: Decorated async functions report 0 time · Issue #55 · realpython/codetiming
X Title: Decorated async functions report 0 time · Issue #55 · realpython/codetiming
Description: 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="{na...
Open Graph Description: 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_fun...
X Description: 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=&qu...
Opengraph URL: https://github.com/realpython/codetiming/issues/55
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Decorated async functions report 0 time","articleBody":"Hi\n\nThis library is very handy but seems it can't be used with async fns - where it would be very helpful. Simple example:\n\n```\nimport asyncio\nimport time\nimport codetiming\n\n@codetiming.Timer(name=\"my_func\", initial_text='Started...', text=\"{name} complete in {:.4f} secs\")\ndef my_func():\n time.sleep(5)\n print('done')\n\n@codetiming.Timer(name=\"my_async_func\", initial_text='Started...', text=\"{name} complete in {:.4f} secs\")\nasync def my_async_func():\n time.sleep(5)\n print('done')\n\nmy_func() # timing ok...\n\nloop = asyncio.get_event_loop()\nloop.run_until_complete(my_async_func()) # timing 0.0 sec\n```\n\n\nThis gives output:\n\n```\nStarted...\ndone\nmy_func complete in 5.0052 secs\nStarted...\nmy_async_func complete in 0.0000 secs\ndone\n```\n\nIs there a way to use it to correctly report the actual elapsed time for the async function somehow?\n","author":{"url":"https://github.com/rmaunder","@type":"Person","name":"rmaunder"},"datePublished":"2025-03-22T15:13:47.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/55/codetiming/issues/55"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:20867b41-0e73-70e3-3ba4-d965a666a00f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D91C:27367:9AF868:C54761:697F6E2D |
| html-safe-nonce | 3c1916e086935d6e3999275f1529dc2e898eae3e7dadfad8b88573de50ffcb31 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTFDOjI3MzY3OjlBRjg2ODpDNTQ3NjE6Njk3RjZFMkQiLCJ2aXNpdG9yX2lkIjoiNTk1MDQxNTYzNTQ1OTU2NzE0OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9fab01ffdf7ebf388aa812dcce88c0fa7ba0843e652a5ae3d11ef52529e03ae8 |
| hovercard-subject-tag | issue:2940443423 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/realpython/codetiming/55/issue_layout |
| twitter:image | https://opengraph.githubassets.com/eb82553245423f6a7ca008676225bde8b08cdb3cca96884b2d59d736af389e51/realpython/codetiming/issues/55 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eb82553245423f6a7ca008676225bde8b08cdb3cca96884b2d59d736af389e51/realpython/codetiming/issues/55 |
| og:image:alt | 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_fun... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rmaunder |
| hostname | github.com |
| expected-hostname | github.com |
| None | 60279d4097367e16897439d16d6bbe4180663db828c666eeed2656988ffe59f6 |
| turbo-cache-control | no-preview |
| go-import | github.com/realpython/codetiming git https://github.com/realpython/codetiming.git |
| octolytics-dimension-user_id | 5448020 |
| octolytics-dimension-user_login | realpython |
| octolytics-dimension-repository_id | 199325522 |
| octolytics-dimension-repository_nwo | realpython/codetiming |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 199325522 |
| octolytics-dimension-repository_network_root_nwo | realpython/codetiming |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7c85641c598ad130c74f7bcc27f58575cac69551 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width