Repository navigation
Adds a request timeout to the sync client, plus two small request fixes - #32
Open
V Anbu chelvan (ZANYANBU) wants to merge 1 commit into
Open
V Anbu chelvan (ZANYANBU) wants to merge 1 commit into
V Anbu chelvan (ZANYANBU) wants to merge 1 commit into
Conversation
- DialpadClient sent its requests with no timeout, so a request that never got an answer blocked the caller forever. Both clients now take a `timeout` argument, defaulting to the 600 seconds the async client already used. Passing None restores the old behaviour. - The Authorization and DP-Company-ID headers were written into the headers dict passed in by the caller, which left the caller's dict holding the API token. The clients now work on a copy. - `del client.company_id` removed the underlying attribute, so every later request raised AttributeError. Deleting it now resets it to None.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three small fixes to the hand-written request code in
client.pyandasync_client.py. No generated files are touched.1. The sync client never times out
DialpadClientcallsrequestswithout atimeout, andrequestshas no default, so a request that never gets an answer blocks the caller forever.AsyncDialpadClientalready uses 600 seconds.Both clients now accept a
timeoutargument that defaults to the same 600 seconds.timeout=Nonegives the previous behaviour of the sync client.2. The caller's
headersdict is modified_raw_requestdoesheaders = headers or dict()and then addsAuthorizationandDP-Company-IDto it. When a caller passes its own dict torequest()/iter_request(), that dict is left holding the API token:The clients now work on a copy.
3.
del client.company_idbreaks the clientThe deleter removes
_company_id, so the next request fails in_raw_request:Deleting it now resets it to
None.Tests
test/test_client_requests.pycovers each fix for both clients (8 tests). They fail onmasterand pass with this change.The README lists the new
timeoutargument. I have not bumped the version; happy to if you would like that in this PR.