-
Notifications
You must be signed in to change notification settings - Fork 97
Create commands after payload conversion #591
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
Conversation
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.
LGTM!
) | ||
command = self._add_command() | ||
command.respond_to_query.query_id = job.query_id | ||
command.respond_to_query.succeeded.response.CopyFrom(result_payloads[0]) |
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.
Non-blocking: in general my view is that try
blocks should enclose as little as possible. it seems that these 3 lines could go after?
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.
No because this needs to only be called on the success path, there is a failure path that does another thing, there is no need for any common code after the try
except Exception as err: | ||
try: | ||
command = self._add_command() | ||
command.respond_to_query.query_id = job.query_id |
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.
Non-blocking: I assume these lines cannot raise an exception; I would put them outside the try
.
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.
They were outside of try in the previous code, but the purpose of this fix is to not invoke these until it's time to make the command because if you call this before an exception is raised, you'll have an unfinished command that was added
What was changed
Before this change, the Python SDK added commands on the activation completion before payload conversion and then filled them out including with conversion. This meant that in cases where the payload converter caused a application error (or was caught), the command would be half created/filled-in and you'd get errors like "invalid TaskQueue on ScheduleActivityTaskCommand: missing task queue name".
Now, in multiple places, we do the payload conversion before command creation/addition which allows exceptions to occur before the command is added.
Checklist