Skip to content

[ASOC-2886] Add retries when sending graphql requests#38

Merged
samanthamcq merged 4 commits into
mainfrom
ASOC-2886
Dec 17, 2024
Merged

[ASOC-2886] Add retries when sending graphql requests#38
samanthamcq merged 4 commits into
mainfrom
ASOC-2886

Conversation

@samanthamcq

@samanthamcq samanthamcq commented Dec 11, 2024

Copy link
Copy Markdown
Collaborator

ASOC-2886 - Fixed an issue with the SDK that was either not working or failing intermittently. Added retries (up to 10 times) for queries, but skips retries for mutations.

Comment thread finite_state_sdk/__init__.py Outdated
return records


@retry(stop=stop_after_attempt(10), wait=wait_fixed(10), retry=retry_if_exception(is_not_breakout_exception))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i think this is too many retries, maybe 3? 5? how long does the test take to run?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Changed to 5

Comment on lines +78 to +79
# Call the function and expect a RetryError
with pytest.raises(tenacity.RetryError) as excinfo:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if this test takes too long to run (cause of all the retries) you can add a send_graphql_query.retry.wait = wait_fixed(0) in the test itself to override the wait

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It only takes couple minutes.

# Assertion
assert str(excinfo.value) == "Error: 500 - Internal Server Error"
# Check the inner exception message
inner_exception = excinfo.value.last_attempt.exception()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could also assert the number of calls to post here

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

added

@samanthamcq samanthamcq merged commit f1b277f into main Dec 17, 2024
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