Skip to content

execute_query_retry in client_runtime_context.py may leave the context in a dirty state #938

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
npetzall-vcc opened this issue Feb 10, 2025 · 0 comments

Comments

@npetzall-vcc
Copy link

def execute_query_retry(
self,
max_retry=5,
timeout_secs=5,
success_callback=None,
failure_callback=None,
exceptions=(ClientRequestException,),
):
"""
Executes the current set of data retrieval queries and method invocations and retries it if needed.
:param int max_retry: Number of times to retry the request
:param int timeout_secs: Seconds to wait before retrying the request.
:param (office365.runtime.client_object.ClientObject)-> None success_callback:
:param (int, requests.exceptions.RequestException)-> None failure_callback:
:param exceptions: tuple of exceptions that we retry
"""
for retry in range(1, max_retry + 1):
try:
self.execute_query()
if callable(success_callback):
success_callback(self.current_query.return_type)
break
except exceptions as e:
self.add_query(self.current_query)
if callable(failure_callback):
failure_callback(retry, e)
sleep(timeout_secs)

If the last attempt fails with a ClientRequestException it will still re-queue the query.
But it will never consume it, since line 63 would never be called again. Unless the context is re-used and the query would be executed for a different item which could cause all sorts of issues.

Since there is no exception/error raised when max attempts have been performed.
This dirty state is unknown unless failure callback is implemented to keep track of this, clear() is called after each use or context is re-created after each use.

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

No branches or pull requests

2 participants