mirror of
https://github.com/python/cpython.git
synced 2025-07-30 06:34:15 +00:00
Patch #1599845: Add an option to disable the implicit calls to server_bind() and server_activate() in the constructors for TCPServer, SimpleXMLRPCServer and DocXMLRPCServer.
This commit is contained in:
parent
3351aa7dd5
commit
ae04106a0e
6 changed files with 30 additions and 12 deletions
|
@ -14,8 +14,12 @@ HTTP GET requests. Servers can either be free standing, using
|
||||||
\class{DocXMLRPCServer}, or embedded in a CGI environment, using
|
\class{DocXMLRPCServer}, or embedded in a CGI environment, using
|
||||||
\class{DocCGIXMLRPCRequestHandler}.
|
\class{DocCGIXMLRPCRequestHandler}.
|
||||||
|
|
||||||
\begin{classdesc}{DocXMLRPCServer}{addr\optional{,
|
\begin{classdesc}{DocXMLRPCServer}{addr\optional{,
|
||||||
requestHandler\optional{, logRequests}}}
|
requestHandler\optional{,
|
||||||
|
logRequests\optional{,
|
||||||
|
allow_none\optional{,
|
||||||
|
encoding\optional{,
|
||||||
|
bind_and_activate}}}}}}
|
||||||
|
|
||||||
Create a new server instance. All parameters have the same meaning as
|
Create a new server instance. All parameters have the same meaning as
|
||||||
for \class{SimpleXMLRPCServer.SimpleXMLRPCServer};
|
for \class{SimpleXMLRPCServer.SimpleXMLRPCServer};
|
||||||
|
|
|
@ -15,7 +15,9 @@ CGI environment, using \class{CGIXMLRPCRequestHandler}.
|
||||||
|
|
||||||
\begin{classdesc}{SimpleXMLRPCServer}{addr\optional{,
|
\begin{classdesc}{SimpleXMLRPCServer}{addr\optional{,
|
||||||
requestHandler\optional{,
|
requestHandler\optional{,
|
||||||
logRequests\optional{, allow_none\optional{, encoding}}}}}
|
logRequests\optional{,
|
||||||
|
allow_none\optional{,
|
||||||
|
encoding}}}}}
|
||||||
|
|
||||||
Create a new server instance. This class
|
Create a new server instance. This class
|
||||||
provides methods for registration of functions that can be called by
|
provides methods for registration of functions that can be called by
|
||||||
|
@ -28,8 +30,13 @@ CGI environment, using \class{CGIXMLRPCRequestHandler}.
|
||||||
setting this parameter to false will turn off logging.
|
setting this parameter to false will turn off logging.
|
||||||
The \var{allow_none} and \var{encoding} parameters are passed on to
|
The \var{allow_none} and \var{encoding} parameters are passed on to
|
||||||
\module{xmlrpclib} and control the XML-RPC responses that will be returned
|
\module{xmlrpclib} and control the XML-RPC responses that will be returned
|
||||||
from the server.
|
from the server. The \var{bind_and_activate} parameter controls whether
|
||||||
|
\method{server_bind()} and \method{server_activate()} are called immediately
|
||||||
|
by the constructor; it defaults to true. Setting it to false allows code to
|
||||||
|
manipulate the \var{allow_reuse_address} class variable before the address
|
||||||
|
is bound.
|
||||||
\versionchanged[The \var{allow_none} and \var{encoding} parameters were added]{2.5}
|
\versionchanged[The \var{allow_none} and \var{encoding} parameters were added]{2.5}
|
||||||
|
\versionchanged[The \var{bind_and_activate} parameter was added]{2.6}
|
||||||
\end{classdesc}
|
\end{classdesc}
|
||||||
|
|
||||||
\begin{classdesc}{CGIXMLRPCRequestHandler}{\optional{allow_none\optional{, encoding}}}
|
\begin{classdesc}{CGIXMLRPCRequestHandler}{\optional{allow_none\optional{, encoding}}}
|
||||||
|
|
|
@ -252,8 +252,10 @@ class DocXMLRPCServer( SimpleXMLRPCServer,
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, addr, requestHandler=DocXMLRPCRequestHandler,
|
def __init__(self, addr, requestHandler=DocXMLRPCRequestHandler,
|
||||||
logRequests=1):
|
logRequests=1, allow_none=False, encoding=None,
|
||||||
SimpleXMLRPCServer.__init__(self, addr, requestHandler, logRequests)
|
bind_and_activate=True):
|
||||||
|
SimpleXMLRPCServer.__init__(self, addr, requestHandler, logRequests,
|
||||||
|
allow_none, encoding, bind_and_activate)
|
||||||
XMLRPCDocGenerator.__init__(self)
|
XMLRPCDocGenerator.__init__(self)
|
||||||
|
|
||||||
class DocCGIXMLRPCRequestHandler( CGIXMLRPCRequestHandler,
|
class DocCGIXMLRPCRequestHandler( CGIXMLRPCRequestHandler,
|
||||||
|
|
|
@ -518,11 +518,11 @@ class SimpleXMLRPCServer(SocketServer.TCPServer,
|
||||||
allow_reuse_address = True
|
allow_reuse_address = True
|
||||||
|
|
||||||
def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler,
|
def __init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler,
|
||||||
logRequests=True, allow_none=False, encoding=None):
|
logRequests=True, allow_none=False, encoding=None, bind_and_activate=True):
|
||||||
self.logRequests = logRequests
|
self.logRequests = logRequests
|
||||||
|
|
||||||
SimpleXMLRPCDispatcher.__init__(self, allow_none, encoding)
|
SimpleXMLRPCDispatcher.__init__(self, allow_none, encoding)
|
||||||
SocketServer.TCPServer.__init__(self, addr, requestHandler)
|
SocketServer.TCPServer.__init__(self, addr, requestHandler, bind_and_activate)
|
||||||
|
|
||||||
# [Bug #1222790] If possible, set close-on-exec flag; if a
|
# [Bug #1222790] If possible, set close-on-exec flag; if a
|
||||||
# method spawns a subprocess, the subprocess shouldn't have
|
# method spawns a subprocess, the subprocess shouldn't have
|
||||||
|
|
|
@ -279,7 +279,7 @@ class TCPServer(BaseServer):
|
||||||
|
|
||||||
Methods for the caller:
|
Methods for the caller:
|
||||||
|
|
||||||
- __init__(server_address, RequestHandlerClass)
|
- __init__(server_address, RequestHandlerClass, bind_and_activate=True)
|
||||||
- serve_forever()
|
- serve_forever()
|
||||||
- handle_request() # if you don't use serve_forever()
|
- handle_request() # if you don't use serve_forever()
|
||||||
- fileno() -> int # for select()
|
- fileno() -> int # for select()
|
||||||
|
@ -322,13 +322,14 @@ class TCPServer(BaseServer):
|
||||||
|
|
||||||
allow_reuse_address = False
|
allow_reuse_address = False
|
||||||
|
|
||||||
def __init__(self, server_address, RequestHandlerClass):
|
def __init__(self, server_address, RequestHandlerClass, bind_and_activate=True):
|
||||||
"""Constructor. May be extended, do not override."""
|
"""Constructor. May be extended, do not override."""
|
||||||
BaseServer.__init__(self, server_address, RequestHandlerClass)
|
BaseServer.__init__(self, server_address, RequestHandlerClass)
|
||||||
self.socket = socket.socket(self.address_family,
|
self.socket = socket.socket(self.address_family,
|
||||||
self.socket_type)
|
self.socket_type)
|
||||||
self.server_bind()
|
if bind_and_activate:
|
||||||
self.server_activate()
|
self.server_bind()
|
||||||
|
self.server_activate()
|
||||||
|
|
||||||
def server_bind(self):
|
def server_bind(self):
|
||||||
"""Called by constructor to bind the socket.
|
"""Called by constructor to bind the socket.
|
||||||
|
|
|
@ -156,6 +156,10 @@ Core and builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Patch #1599845: Add an option to disable the implicit calls to server_bind()
|
||||||
|
and server_activate() in the constructors for TCPServer, SimpleXMLRPCServer
|
||||||
|
and DocXMLRPCServer.
|
||||||
|
|
||||||
- Bug #1531963: Make SocketServer.TCPServer's server_address always
|
- Bug #1531963: Make SocketServer.TCPServer's server_address always
|
||||||
be equal to calling getsockname() on the server's socket. Fixed by
|
be equal to calling getsockname() on the server's socket. Fixed by
|
||||||
patch #1545011.
|
patch #1545011.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue