Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
afefcfd4
Commit
afefcfd4
authored
Jun 07, 2009
by
Kristján Valur Jónsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http://bugs.python.org/issue6192
Add a feature to disable the Nagle algorithm on sockets in TCPServer
parent
e021c9cb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
Doc/library/socketserver.rst
Doc/library/socketserver.rst
+9
-0
Lib/SocketServer.py
Lib/SocketServer.py
+7
-1
No files found.
Doc/library/socketserver.rst
View file @
afefcfd4
...
...
@@ -223,6 +223,15 @@ The server classes support the following class variables:
desired. If :meth:`handle_request` receives no incoming requests within the
timeout period, the :meth:`handle_timeout` method is called.
.. attribute:: TCPServer.disable_nagle_algorithm
If set to True, it will set the TCP_NODELAY attribute of new requests
connections. This can help alleviate problems with latency in
request-response type applications. To avoid sending many small packets,
this option should be used only when bufferning output, such as when
setting :attr:`StreamRequestHandler.wbufsize` attribute to -1.
.. versionadded:: 2.7
There are various server methods that can be overridden by subclasses of base
server classes like :class:`TCPServer`; these methods aren't useful to external
...
...
Lib/SocketServer.py
View file @
afefcfd4
...
...
@@ -374,6 +374,7 @@ class TCPServer(BaseServer):
- socket_type
- request_queue_size (only for stream sockets)
- allow_reuse_address
- disable_nagle_algorithm
Instance variables:
...
...
@@ -391,6 +392,8 @@ class TCPServer(BaseServer):
allow_reuse_address
=
False
disable_nagle_algorithm
=
False
def
__init__
(
self
,
server_address
,
RequestHandlerClass
,
bind_and_activate
=
True
):
"""Constructor. May be extended, do not override."""
BaseServer
.
__init__
(
self
,
server_address
,
RequestHandlerClass
)
...
...
@@ -441,7 +444,10 @@ class TCPServer(BaseServer):
May be overridden.
"""
return
self
.
socket
.
accept
()
request
=
self
.
socket
.
accept
()
if
self
.
disable_nagle_algorithm
:
request
[
0
].
setsockopt
(
socket
.
IPPROTO_TCP
,
socket
.
TCP_NODELAY
,
True
)
return
request
def
close_request
(
self
,
request
):
"""Called to clean up an individual request."""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment