Skip to content

feat: wait for actions using ActionsClient.wait_for - #508

Draft
jooola wants to merge 2 commits into
mainfrom
wait_for_actions
Draft

feat: wait for actions using ActionsClient.wait_for#508
jooola wants to merge 2 commits into
mainfrom
wait_for_actions

Conversation

@jooola

Copy link
Copy Markdown
Member

This function allows the users to wait for multiple actions in an efficient way. All actions are queried using a single call, which reduce the potential for running into rate limits.

@codecov

codecovBot commented Jun 20, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.86047% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.95%. Comparing base (48f3424) to head (aebbbab).

Files with missing linesPatch %Lines
hcloud/actions/client.py92.00%4 Missing ⚠️
hcloud/_utils.py91.42%3 Missing ⚠️
Additional details and impacted files
@@ Coverage Diff @@## main #508 +/- ##
==========================================
- Coverage 97.07% 96.95% -0.13% 
==========================================
Files 76 77 +1 Lines 4036 4105 +69 ==========================================
+ Hits 3918 3980 +62 - Misses 118 125 +7 

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jooolajooola changed the title feat: wait for actions using ActionsClient.wait_for and ActionsClient.wait_for_funcfeat: wait for actions using ActionsClient.{wait_for,wait_for_function}Jun 20, 2025
@jooolajooola changed the title feat: wait for actions using ActionsClient.{wait_for,wait_for_function}feat: wait for actions using ActionsClient.wait_forJun 20, 2025
@jooola
jooola requested a review from apricoteJune 20, 2025 13:22
@jooola
jooolaforce-pushed the wait_for_actions branch 2 times, most recently from 34685b8 to 4639148CompareJune 23, 2025 13:15
Comment threadhcloud/actions/client.py
Comment threadhcloud/actions/client.py Outdated
Comment on lines +209 to +211
raise ActionGroupException(
[ActionTimeoutException(action=action) for action in running]
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This hides/ignores any errors for actions that already completed. Should they be included in the Exception or should users that want this behavior pass their own handle_update callable and track these action errors themselves?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Not entirely sure about this one.

I doubt there is a use case for having the actions that succeeded, we are more focused on the actions that timeout.

I think usage will tell, so I'll start using this in the ansible collection and see how this works out.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, I was not clear enough. Besides the actions that time out, maybe the user is also interested in the actions that errored, to show a full picture of the issues.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

If an action failed, we raise ActionFailedException and won't run into the ActionTimeoutException or ActionGroupException. So timeout only happens when everything is still running, hence why we do not handle it here.

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

And to actually answer your question: if the users uses the wait_for_function, they might have to managed the errors themselves.

@jooolajooolaJul 31, 2026

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

Python 3.10 EOL is in 3 months (~31 Oct 2026), so I think we can wait until them to:

So we don't have to use this weird ActionGroupException, which is once of the reason why this PR has stalled for some time now.

Comment threadhcloud/actions/client.py Outdated
@jooola
jooolaforce-pushed the wait_for_actions branch 2 times, most recently from 8064421 to 0a0046aCompareJune 26, 2025 13:16
@github-actions

Copy link
Copy Markdown

This PR has been marked as stale because it has not had recent activity. The bot will close the PR if no further action occurs.

jooola added 2 commits July 31, 2026 14:10
This function allows the users to wait for multiple actions in an efficient way. All actions are queried using a single call, which reduce the potential for running into rate limits.
In addition, users may also configure a duration based timeout when waiting for actions using:
action.wait_until_finished(timeout=10) # 10 seconds
# or
client.actions.wait_for(..., timeout=10)
@jooola
jooola marked this pull request as draft July 31, 2026 12:18
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@jooola@apricote