Skip to content

fix: return each async request its own response instead of the shared attribute - #975

Open
andret13pinto wants to merge 1 commit into
twilio:mainfrom
andret13pinto:fix/async-client-concurrent-responses
Open

andret13pinto wants to merge 1 commit into
twilio:mainfrom
andret13pinto:fix/async-client-concurrent-responses

Conversation

@andret13pinto

Copy link
Copy Markdown

Fixes #974

AsyncTwilioHttpClient.request stored the response in self._test_only_last_response and returned that attribute. With pool_connections=False the method awaits session.close() after the store. A request that starts during that await resets the attribute. The first request then returns None or the other request's response.

The method now keeps the response in a local variable and returns it. It still sets the test-only attribute, so the tests that read it keep working.

The new test runs two requests concurrently on one client with a session that yields on close, and checks that each gets its own response. It fails on main and passes with the fix.

… attribute

AsyncTwilioHttpClient.request stored the response on the instance and returned that attribute. With pool_connections=False it awaits session.close() after the store, so a request that starts during that await resets the attribute and the first request returns None or the other request's response. The response now lives in a local variable; the test-only attribute is still set for the tests that read it.

This branch has not been deployed

No deployments
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.

[BUG] AsyncTwilioHttpClient returns another request's response under concurrency

1 participant