[Python-checkins] r73277 - in python/branches/tk_and_idle_maintenance: Doc/library/socketserver.rst Lib/SocketServer.py Lib/locale.py Misc/developers.txt Modules/_localemodule.c
guilherme.polo
python-checkins at python.org
Sun Jun 7 23:22:26 CEST 2009
Author: guilherme.polo
Date: Sun Jun 7 23:22:25 2009
New Revision: 73277
Log:
Merged revisions 73270,73272,73275 via svnmerge from
svn+ssh://pythondev/python/trunk
........
r73270 | benjamin.peterson | 2009-06-07 13:24:48 -0300 (Sun, 07 Jun 2009) | 1 line
backport r73268
........
r73272 | kristjan.jonsson | 2009-06-07 13:43:23 -0300 (Sun, 07 Jun 2009) | 2 lines
http://bugs.python.org/issue6192
Add a feature to disable the Nagle algorithm on sockets in TCPServer
........
r73275 | georg.brandl | 2009-06-07 17:37:52 -0300 (Sun, 07 Jun 2009) | 1 line
Add Ezio.
........
Modified:
python/branches/tk_and_idle_maintenance/ (props changed)
python/branches/tk_and_idle_maintenance/Doc/library/socketserver.rst
python/branches/tk_and_idle_maintenance/Lib/SocketServer.py
python/branches/tk_and_idle_maintenance/Lib/locale.py
python/branches/tk_and_idle_maintenance/Misc/developers.txt
python/branches/tk_and_idle_maintenance/Modules/_localemodule.c
Modified: python/branches/tk_and_idle_maintenance/Doc/library/socketserver.rst
==============================================================================
--- python/branches/tk_and_idle_maintenance/Doc/library/socketserver.rst (original)
+++ python/branches/tk_and_idle_maintenance/Doc/library/socketserver.rst Sun Jun 7 23:22:25 2009
@@ -223,6 +223,15 @@
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
Modified: python/branches/tk_and_idle_maintenance/Lib/SocketServer.py
==============================================================================
--- python/branches/tk_and_idle_maintenance/Lib/SocketServer.py (original)
+++ python/branches/tk_and_idle_maintenance/Lib/SocketServer.py Sun Jun 7 23:22:25 2009
@@ -374,6 +374,7 @@
- socket_type
- request_queue_size (only for stream sockets)
- allow_reuse_address
+ - disable_nagle_algorithm
Instance variables:
@@ -391,6 +392,8 @@
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 @@
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."""
Modified: python/branches/tk_and_idle_maintenance/Lib/locale.py
==============================================================================
--- python/branches/tk_and_idle_maintenance/Lib/locale.py (original)
+++ python/branches/tk_and_idle_maintenance/Lib/locale.py Sun Jun 7 23:22:25 2009
@@ -529,10 +529,8 @@
"""
_setlocale(category, _build_localename(getdefaultlocale()))
-if sys.platform in ('win32', 'darwin', 'mac'):
+if sys.platform.startswith("win"):
# On Win32, this will return the ANSI code page
- # On the Mac, it should return the system encoding;
- # it might return "ascii" instead
def getpreferredencoding(do_setlocale = True):
"""Return the charset that the user is likely using."""
import _locale
Modified: python/branches/tk_and_idle_maintenance/Misc/developers.txt
==============================================================================
--- python/branches/tk_and_idle_maintenance/Misc/developers.txt (original)
+++ python/branches/tk_and_idle_maintenance/Misc/developers.txt Sun Jun 7 23:22:25 2009
@@ -17,6 +17,9 @@
Permissions History
-------------------
+- Ezio Melotti was given SVN access on June 7 2009 by GFB, for work on and
+ fixes to the documentation.
+
- Paul Kippes was given commit privileges at PyCon 2009 by BAC to work on 3to2.
- Ron DuPlain was given commit privileges at PyCon 2009 by BAC to work on 3to2.
Modified: python/branches/tk_and_idle_maintenance/Modules/_localemodule.c
==============================================================================
--- python/branches/tk_and_idle_maintenance/Modules/_localemodule.c (original)
+++ python/branches/tk_and_idle_maintenance/Modules/_localemodule.c Sun Jun 7 23:22:25 2009
@@ -412,38 +412,6 @@
}
#endif
-#if defined(__APPLE__)
-/*
-** Find out what the current script is.
-** Donated by Fredrik Lundh.
-*/
-static char *mac_getscript(void)
-{
- CFStringEncoding enc = CFStringGetSystemEncoding();
- static CFStringRef name = NULL;
- /* Return the code name for the encodings for which we have codecs. */
- switch(enc) {
- case kCFStringEncodingMacRoman: return "mac-roman";
- case kCFStringEncodingMacGreek: return "mac-greek";
- case kCFStringEncodingMacCyrillic: return "mac-cyrillic";
- case kCFStringEncodingMacTurkish: return "mac-turkish";
- case kCFStringEncodingMacIcelandic: return "mac-icelandic";
- /* XXX which one is mac-latin2? */
- }
- if (!name) {
- /* This leaks an object. */
- name = CFStringConvertEncodingToIANACharSetName(enc);
- }
- return (char *)CFStringGetCStringPtr(name, 0);
-}
-
-static PyObject*
-PyLocale_getdefaultlocale(PyObject* self)
-{
- return Py_BuildValue("Os", Py_None, mac_getscript());
-}
-#endif
-
#ifdef HAVE_LANGINFO_H
#define LANGINFO(X) {#X, X}
static struct langinfo_constant{
@@ -689,7 +657,7 @@
METH_VARARGS, strcoll__doc__},
{"strxfrm", (PyCFunction) PyLocale_strxfrm,
METH_VARARGS, strxfrm__doc__},
-#if defined(MS_WINDOWS) || defined(__APPLE__)
+#if defined(MS_WINDOWS)
{"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, METH_NOARGS},
#endif
#ifdef HAVE_LANGINFO_H
More information about the Python-checkins
mailing list