Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyO3's coroutine type has accessible execution state #4807

Open
MacMoneysac123 opened this issue Dec 19, 2024 · 1 comment
Open

PyO3's coroutine type has accessible execution state #4807

MacMoneysac123 opened this issue Dec 19, 2024 · 1 comment

Comments

@MacMoneysac123
Copy link

Hi,
At first I want to thank you for this awesome project!

Currently, (version 0.23.3), the coroutine type implemented by PyO3 has not attributes such as cr_running, cr_suspended or cr_frame. However, inspecting the status of the coroutine by inspect.getcoroutinestate(my_coro()) results in an exception.

Our use case is to monitor the status of tasks and coroutines to have more insights in their live cycle. It would be quite nice to have at least alternatives attributes or methods to access somehow the state of the coroutine (created/running/suspended/closed).

A current workaround is to wrap pyO3"s coroutine with a usual python coroutine in python code.

I guess in first place it would be a question of design rather implementation.

Thanks 😊

@davidhewitt
Copy link
Member

Thanks for flagging this, it's an interesting question.

Ideally I would prefer PyO3 not have a custom coroutine type but use the standard one, I suspect that things like not having a Python frame would make that complicated though. So for the foreseeable future it will remain as is.

Can you elaborate more on the attributes you access? Are they private? I'm sort of ok exposing attributes for introspection as long as they're public on coroutines and we think adding them won't constrain future development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants