Skip to content

Activity worker refactor #860

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Activity worker refactor #860

wants to merge 2 commits into from

Conversation

dandavison
Copy link
Contributor

@dandavison dandavison commented May 8, 2025

This is pure refactoring for readability. I found it very helpful while creating a Nexus worker that is similar in some respects to the activity worker. All this PR does is move us to this pattern:

        try:
            await self._execute_activity(start, running_activity, completion) # 170 lines
        except BaseException as err:
            # 80 lines of error handling plus sending completion

i.e. separating the execution logic from the error handling, since it's very hard to read a try...except with 170 lines in the middle.

@dandavison dandavison marked this pull request as ready for review May 8, 2025 22:30
@dandavison dandavison requested a review from a team as a code owner May 8, 2025 22:30
Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the biggest fan of de-inlining single-use logic for running an activity from run_activity when it is only used in one place. If anything, I could understand exception handling being de-inlined if it was really too long for you. But not enough disagreement to prevent the change.

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

Successfully merging this pull request may close these issues.

2 participants