-
Notifications
You must be signed in to change notification settings - Fork 110
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
Add batch request callback hook #145
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, would be good to add some tests for this.
@vilasj, I augmented a test to use this hook. I'm not sure if you want something more focused, or if it should be used more broadly, etc. I welcome any advice on how to best test this. Thanks! |
@@ -185,7 +193,8 @@ def testSingleRequestInBatch(self): | |||
'desired_request': desired_request, | |||
}) | |||
|
|||
api_request_responses = batch_api_request.Execute(FakeHttp()) | |||
api_request_responses = batch_api_request.Execute( | |||
FakeHttp(), batch_request_callback=_Callback) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will pass if the callback is never executed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah drat, you're right. I've updated the test. Meant to add that originally...
@@ -150,9 +150,18 @@ def testRequestServiceUnavailable(self): | |||
exceptions.HttpError) | |||
|
|||
def testSingleRequestInBatch(self): | |||
desired_url = 'https://www.example.com' | |||
|
|||
callback_was_called = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: Just curious, why list instead of just an integer count?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Python weirdness about callbacks and mutable variables. Calling a function on a variable will work 100% of the time, otherwise I need to mess with the global keyword.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, thanks for clarification.
Looks like there are some lint failures... |
Yeah I saw the lint failures. I'll fix and resubmit. |
@vilasj fixed the lint error. |
This allows custom error handling etc in the case of batch requests, similar to what is possible in single request mode.