-
-
Notifications
You must be signed in to change notification settings - Fork 344
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
Make it easier to see if a Task
is created/running/exited
#3079
Comments
I don't know the performance characteristics of |
This doesn't need to be the fastest and I would prefer an enum over two methods because otherwise we can represent states that are impossible (a task that exited but hasn't started?). In addition, defined correctly, an enum allows for simple comparison: >>> import enum
>>> class LifecycleEnum(enum.Enum):
... A = enum.auto()
... B = enum.auto()
... C = enum.auto()
...
>>> LifecycleEnum.A.value < LifecycleEnum.B.value
True (We can use specific numbers rather than |
In general I find enums to be much more cumbersome to work with, |
In some of my own code, I've used enums with |
It is currently possible to check the status of a task with https://docs.python.org/3/library/inspect.html#inspect.getcoroutinestate, but this is fairly obscure and not very readable.
We should either document this, or add properties to
Task
that are easy to interface with.For implementing it, I think
has_started() -> bool
andhas_exited -> bool
would be a clean way of doing it.I personally encountered this in #3035 (comment) which would only be for internal use, but I'm guessing it might be useful enough to surface in the public API.
See discussion in Gitter: https://matrix.to/#/!OqDVTrmPstKzivLwZW:gitter.im/$umF5oOw9d2Z20gb95GF_C48HyBi2l6eD3ZW4r_4ark0?via=gitter.im&via=matrix.org&via=zoltan.site
The text was updated successfully, but these errors were encountered: