-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Get rid of legacy class StreamWriter #2109 #2651
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
75cef16
Get rid of legacy StreamWriter (#2623)
pfreixes 6316553
Add CHANGES
pfreixes 050f36a
Merge branch 'master' into remove_streamwriter
pfreixes 58d14a2
Fixed invalid import order
pfreixes 95eba9c
Fix test broken
pfreixes 87fddb1
Fix tcp_cork issues
pfreixes 4d977fa
Test PayloadWriter properties
pfreixes 87928be
Avoid return useless values for tcp_<operations>
pfreixes 4a63159
Merge branch 'master' into remove_streamwriter
pfreixes c9673ad
Increase coverage http_writer
pfreixes 884a4cf
Increase coverage web_protocol
pfreixes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Get rid of the legacy class StreamWriter. |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
"""Helper methods to tune a TCP connection""" | ||
|
||
import socket | ||
from contextlib import suppress | ||
|
||
|
||
__all__ = ('tcp_keepalive', 'tcp_nodelay', 'tcp_cork') | ||
|
||
|
||
if hasattr(socket, 'TCP_CORK'): # pragma: no cover | ||
CORK = socket.TCP_CORK | ||
elif hasattr(socket, 'TCP_NOPUSH'): # pragma: no cover | ||
CORK = socket.TCP_NOPUSH | ||
else: # pragma: no cover | ||
CORK = None | ||
|
||
|
||
if hasattr(socket, 'SO_KEEPALIVE'): | ||
def tcp_keepalive(transport): | ||
sock = transport.get_extra_info('socket') | ||
if sock is not None: | ||
sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) | ||
else: | ||
def tcp_keepalive(transport): # pragma: no cover | ||
pass | ||
|
||
|
||
def tcp_nodelay(transport, value): | ||
sock = transport.get_extra_info('socket') | ||
|
||
if sock is None: | ||
return | ||
|
||
if sock.family not in (socket.AF_INET, socket.AF_INET6): | ||
return | ||
|
||
value = bool(value) | ||
|
||
# socket may be closed already, on windows OSError get raised | ||
with suppress(OSError): | ||
sock.setsockopt( | ||
socket.IPPROTO_TCP, socket.TCP_NODELAY, value) | ||
|
||
|
||
def tcp_cork(transport, value): | ||
sock = transport.get_extra_info('socket') | ||
|
||
if CORK is None: | ||
return | ||
|
||
if sock is None: | ||
return | ||
|
||
if sock.family not in (socket.AF_INET, socket.AF_INET6): | ||
return | ||
|
||
value = bool(value) | ||
|
||
with suppress(OSError): | ||
sock.setsockopt( | ||
socket.IPPROTO_TCP, CORK, value) |
This file contains 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
Oops, something went wrong.
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.
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.
Please add a test for the property
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.
Done.