-
Notifications
You must be signed in to change notification settings - Fork 81
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
New API to wait for handler executions to complete and warnings on unfinished handler executions #556
Conversation
bea62d5
to
6e9cf4c
Compare
temporalio/workflow.py
Outdated
return with_name(fn.__name__, fn) | ||
return partial(decorator, name, unfinished_handlers_policy) | ||
else: | ||
return decorator(fn.__name__, unfinished_handlers_policy, fn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes make the decorator behave consistently: permitting e.g. @update()
with the same meaning as @update
, and allowing the default value of the handler policy to be passed explicitly as a param if the user desires. That makes sense, especially now that we're adding a 3rd parameter to the decorators which is unrelated to name
and dynamic
. TODO: I'll need to update the query decorator also for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Most of my comments are only on little things.
# signals lack a unique per-invocation identifier, we introduce a sequence number for the | ||
# purpose. | ||
self._handled_signals_seq = 0 | ||
self._in_progress_signals: dict[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if dict
is supported in 3.8, we have used Dict
(from typing
) to be sure to have compatibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I was trying to remember to use the 3.8-compatible upper-cased names but it's easy to forget.
@@ -490,6 +539,7 @@ async def run_update() -> None: | |||
f"Update handler for '{job.name}' expected but not found, and there is no dynamic handler. " | |||
f"known updates: [{' '.join(known_updates)}]" | |||
) | |||
self._in_progress_updates[job.id] = (job, defn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should move to just above the try
for clarity (even though it doesn't matter much in practice, was just a bit confusing to have to hunt down the cases when something undone in a finally was not done)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As things stand, it has to be here, since defn
is bound inside the try
. I agree that the try
should be scoped more tightly around the code which is actually raising the exceptions it's catching, but I think I'll leave that change out of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review @cretz, I've taken almost all the suggestions you made.
# signals lack a unique per-invocation identifier, we introduce a sequence number for the | ||
# purpose. | ||
self._handled_signals_seq = 0 | ||
self._in_progress_signals: dict[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I was trying to remember to use the 3.8-compatible upper-cased names but it's easy to forget.
temporalio/workflow.py
Outdated
# an error rather than the update result. | ||
ABANDON = 1 | ||
# Issue a warning in addition to abandoning. | ||
WARN_AND_ABANDON = 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I had it that way and then changed it to make the comments read better. Changed it back.
temporalio/workflow.py
Outdated
@@ -173,6 +173,20 @@ def run(fn: CallableAsyncType) -> CallableAsyncType: | |||
return fn # type: ignore[return-value] | |||
|
|||
|
|||
class UnfinishedHandlersPolicy(IntEnum): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
7e1fc7b
to
62d7c03
Compare
94bf238
to
9346ac1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This LGTM. Need to disable tests for time-skipping test server and may need to remove an unused import, but overall LGTM.
This PR was missing one thing -- it didn't address cancellation. Discussed with @cretz in a different channel and we agreed that it was a bug that the |
2e39d45
to
f59bcac
Compare
f59bcac
to
3f0b11c
Compare
42e3fc6
to
d6ca246
Compare
54d9ac9
to
6526fb1
Compare
d64fa77
to
b9e07cd
Compare
Closes #538
Implementation ready for review; names are still under discussion.
What was changed
workflow.all_handlers_finished()
.Why?
Workflows exiting while handler executions are in progress is an important category of run-time workflow incorrectness.