This repository has been archived by the owner on Nov 29, 2021. It is now read-only.
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.
This commit improves the way connections are handled by the
handle_client_stream()
method.Previously, data from the client socket was read until a timeout was
reached after two seconds, i.e. when there was no activity from the open
client socket for two seconds. Beyond reaching this timeout or
encountering an error, there was no way to exit the
while True:
loopcontaining the
recv
andread
calls.This lead to problems when a client sent data and waited less than two
seconds before closing the connection. Since the timeout was never
reached, the
data.append()
method continued to appendbytes
to thedata
array indefinitely.This commit introduces a conditional to check if any additional data was
read and to
break
the loop if not, i.e. all data sent by the clientwas consumed.
This has the added benefit of reducing the time the client has to wait
after it is done sending by the two seconds the server previously waited
before starting to process the data.