Timeout improvements - #464
Merged
Merged
Conversation
Contributor
What happened to |
felipediel
commented
Oct 29, 2020
CollaboratorAuthor
I don't think we need this option here because we are not binding to a specific port. The OS will bind to any available port, so we don't need to reuse anything. |
felipedielforce-pushed
the
context-manager
branch
from
November 29, 2020 02:19
3eaad8b to
dc1bb15Comparefelipediel
marked this pull request as draft
December 3, 2020 05:19
felipedielforce-pushed
the
context-manager
branch
2 times, most recently
from
December 3, 2020 21:15
ee9150b to
c488f4eComparefelipediel
marked this pull request as ready for review
December 3, 2020 22:22
felipedielforce-pushed
the
context-manager
branch
2 times, most recently
from
January 10, 2021 22:34
8c6ffdd to
8f2abfdComparefelipedielforce-pushed
the
context-manager
branch
from
January 11, 2021 03:04
8f2abfd to
6af6cffCompare Merged
felipediel added a commit
to felipediel/python-broadlink
that referenced
this pull request
Jan 29, 2021
- Only start to count the timer inside the lock. - Improve precision of the timeout option. - Use a context manager for the connection. - Remove SO_REUSEADDR option. - Amend: Revert retry_intvl (mjg59#506)
felipediel added a commit
to felipediel/python-broadlink
that referenced
this pull request
Jan 29, 2021
- Only start to count the timer inside the lock. - Improve precision of the timeout option. - Use a context manager for the connection. - Remove SO_REUSEADDR option. Amend: Revert retry_intvl (mjg59#506)
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 freeto 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.
Problem 1: False-positive NetworkTimeout() exception
Some operations are blocking. When we send a long RF code, the device takes a long time to respond, but it doesn't mean the connection timed out.
Let's take this code for example:
It takes 4.5s until we get a response from the device. This will prevent the device from sending the code repeatedly when the timeout blows in the inner loop, but even with that fix we need to increase the timeout to avoid throwing a false-positive NetworkTimeout() in the end.
Problem 2: Multi-threads, lock and timeout
When we call device.send_data() (operation A) from thread A and then call device.send_data() (operation B) from thread B before the operation A is finished, we're going to wait for operation A to finish here. But we are starting to count operation B outside the lock, so we can timeout operation B even before it is started. My suggestion is to only start counting inside the lock.
Proposed changes