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

Run event loop after job application #717

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

Conversation

Sushisource
Copy link
Member

@Sushisource Sushisource commented Dec 30, 2024

What was changed

Run the event loop after applying all jobs, rather than after each "batch" of jobs.

Why?

Align with TS & Core's intended method of job application

Checklist

  1. Closes [Feature Request] Consider aligning activation job application with TS changes #606

  2. How was this tested:
    Existing & new tests

  3. Any docs updates needed?

@Sushisource Sushisource requested a review from a team as a code owner December 30, 2024 20:14
Comment on lines +378 to +381
# Ensure the main workflow function task is initialized after a first run of the
# event loop, which might execute before-start signals/updates. This is behind
# a finally because if those handlers fail, we need still need the main routine
# to be initialized in order to fail tasks properly.
Copy link
Member Author

Choose a reason for hiding this comment

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

If it weren't for this bit we would've ended up with net-less code here. A bit too bad, but, I think still nicer than grouping things into batches.

self.events.append("act-2")


async def test_async_loop_ordering(client: Client):
Copy link
Member

@cretz cretz Jan 6, 2025

Choose a reason for hiding this comment

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

Hrmm, I think another test may look like this:

  • Create workflow that has a signal handler that updates some counter and an activity in the background that, when done, updates that same counter. And have the primary workflow method return the counter when it is > 2 (i.e. after wait condition for that).
  • Start the workflow, and while the activity is running, kill the workflow worker
  • While the workflow worker is not running, send two signals and complete the activity
  • Start the workflow worker again and confirm result and confirm that all three of those items (the two signals and the activity completion) came in the same workflow task/activation.

I think with older code, the counter will only reach 2 before workflow returns (i.e. the two signals), but this newer code may return 3 (because it completed the activity before it processed wait condition). I have not tested this though.

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.

[Feature Request] Consider aligning activation job application with TS changes
2 participants