Commit Graph

58 Commits

Author SHA1 Message Date
Ezio Melotti 24b07bcba3 #11515: fix several typos. Patch by Piotr Kasprzyk. 2011-03-15 18:55:01 +02:00
Antoine Pitrou a624040d72 Issue #2302: Fix a race condition in SocketServer.BaseServer.shutdown,
where the method could block indefinitely if called just before the
event loop started running.  This also fixes the occasional freezes
witnessed in test_httpservers.
2010-04-25 21:40:32 +00:00
Kristján Valur Jónsson c71fae5ad7 http://bugs.python.org/issue6382
added the shutdown_request() which can perform shutdown before calling close.  This is needed for the ForkingMixIn because different close semantics are required for child and parent process.  shutdown_request(), for TCP servers, calls socket.shutdown() and then calls close_request().  Therefore, this is not an backwards incompatible change, since subclasses that continue to override close_request() continue to work.
2009-07-07 09:01:34 +00:00
Kristján Valur Jónsson f5b8ea9128 http://bugs.python.org/issue6382
close_request() (which can send a socket.shutdown()) must be called by the child process in a forking server.  The parent must merely close the socket handle.
2009-07-05 20:56:57 +00:00
Kristján Valur Jónsson b5faac73a4 http://bugs.python.org/issue6381
some platforms may raise ENOTCONN if the stack has disconnected the socket on behalf of the peer.
2009-07-03 23:07:07 +00:00
Kristján Valur Jónsson e007860b8b http://bugs.python.org/issue6267
Cumulative patch to http and xmlrpc
2009-06-28 21:04:17 +00:00
Kristján Valur Jónsson f1d11efb72 http://bugs.python.org/issue6192
Move the newly introduced disable_nagle_algorithm flag into the StreamRequestHandler, where it is more appropriate.
2009-06-24 09:17:04 +00:00
Kristján Valur Jónsson afefcfd4bf http://bugs.python.org/issue6192
Add a feature to disable the Nagle algorithm on sockets in TCPServer
2009-06-07 16:43:23 +00:00
Neil Schemenauer c9332fada6 Fix call to os.waitpid, it does not take keyword args. 2009-02-24 04:23:25 +00:00
Georg Brandl e152a77d96 socketserver renaming reversal part 3: move the module into the right
place and fix all references to it.  Closes #2926.
2008-05-24 18:31:28 +00:00
Alexandre Vassalotti fb9ce65a91 Renamed SocketServer to 'socketserver'.
Deprecated old name.
2008-05-12 01:37:10 +00:00
Jeffrey Yasskin e75f59a578 Progress on issue #1193577 by adding a polling .shutdown() method to
SocketServers. The core of the patch was written by Pedro Werneck, but any bugs
are mine. I've also rearranged the code for timeouts in order to avoid
interfering with the shutdown poll.
2008-03-07 06:22:15 +00:00
Jeffrey Yasskin 392c159ad6 Prevent SocketServer.ForkingMixIn from waiting on child processes that it
didn't create, in most cases. When there are max_children handlers running, it
will still wait for any child process, not just handler processes.
2008-02-28 18:03:15 +00:00
Raymond Hettinger 1b5632445b Add diagnostic message to help figure-out why SocketServer tests occasionally crash
when trying to remove a pid that in not in the activechildren list.
2008-02-14 09:32:45 +00:00
Andrew M. Kuchling e45a77adbe Patch #742598 from Michael Pomraning: add .timeout attribute to SocketServer that will call
.handle_timeout() method when no requests are received within the timeout period.
2008-01-19 16:26:13 +00:00
Tim Peters ea5962f86e Whitespace normalization. 2007-03-12 18:07:52 +00:00
Collin Winter ae04106a0e Patch #1599845: Add an option to disable the implicit calls to server_bind() and server_activate() in the constructors for TCPServer, SimpleXMLRPCServer and DocXMLRPCServer. 2007-03-10 14:41:48 +00:00
Collin Winter 22c42ba88c Bug #1531963: Make SocketServer.TCPServer's server_address always be equal to calling getsockname() on the server's socket.
Will backport.
2007-03-10 02:51:26 +00:00
Georg Brandl ca5feabac2 bug [ 957505 ] SocketServer module documentation misleading 2005-07-18 07:38:44 +00:00
Guido van Rossum ebbffd42f3 Fixed a typo in docstring I happened upon. 2005-04-30 00:20:35 +00:00
Raymond Hettinger a617271dbd Use cStringIO where available. 2004-12-31 19:15:26 +00:00
Barry Warsaw b97f0b7654 TCPServer: Fixed typo in class docstring. 2003-10-09 23:48:52 +00:00
Barry Warsaw 3aaad5079b TCPServer: Fixed typo in class docstring.
Backport candidate.
2003-10-09 22:44:05 +00:00
Anthony Baxter 4cedc1e84e Clearing out old patch queue. Patch #558547, make SocketServer more
robust. This makes socketserver's close() method callable repeatedly
without error - similar to other file-like objects.
2003-01-02 03:07:48 +00:00
Fred Drake 132e0e824b Use False instead of 0. 2002-11-22 14:22:49 +00:00
Martin v. Löwis f86e8ef33e Patch #550765: Add daemon_threads flag. 2002-11-22 08:08:44 +00:00
Raymond Hettinger c8f8034512 Replace 0 with False to match working in documentation. SF 599681. 2002-08-25 16:36:49 +00:00
Guido van Rossum beae477767 SF bug #543318 (Frank J. Tobin).
In DatagramRequestHandler.setup(), the wfile initialization should be
StringIO.StringIO(), not StringIO.StringIO(slf.packet).

Bugfix candidate (all the way back to Python 1.5.2 :-).
2002-04-15 00:36:48 +00:00
Tim Peters bc0e910826 Convert a pile of obvious "yes/no" functions to return bool. 2002-04-04 22:55:58 +00:00
Guido van Rossum 83c3281826 Apply the first chunk of the second patch from SF bug #471720:
ThreadingMixIn/TCPServer forgets close (Max Neunhöffer).

This ensures that handle_error() and close_request() are called when
an error occurs in the thread.

(I am not applying the second chunk of the patch, which moved the
finish() call into the finally clause in BaseRequestHandler's __init__
method; that would be a semantic change that I cannot accept at this
point - the data would be sent even if the handler raised an
exception.)
2001-10-23 21:42:45 +00:00
Guido van Rossum a5343ccd28 SF bug #471720: ThreadingMixIn/TCPServer forgets close
Solved with a helper method that calls finish_request() and then
close_request().  The code is by Max Neunhöffer.
2001-10-18 18:02:07 +00:00
Skip Montanaro ae3b1258e4 remove empty __del__ method from BaseRequestHandler to avoid cyclic garbage
loss for no reason.
2001-10-03 12:21:23 +00:00
Martin v. Löwis a43c2f845e Patch #401196: Use getaddrinfo and AF_INET6 in TCP servers and clients. 2001-07-24 20:34:08 +00:00
Guido van Rossum 7de4d645a5 IMPORTANT FIX: This should definitely go into the 2.1.1 release!!!
Fix various serious problems:

- The ThreadingTCPServer class and its derived classes were completely
  broken because the main thread would close the request before the
  handler thread had time to look at it.  This was introduced by
  Ping's close_request() patch.  The fix moves the close_request()
  calls to after the handler has run to completion in the BaseServer
  class and the ForkingMixIn class; when using the ThreadingMixIn,
  closing the request is the handler's responsibility.

- The ForkingUDPServer class has always been been broken because the
  socket was closed in the child before calling the handler.  I fixed
  this by simply not calling server_close() in the child at all.

- I cannot get the UnixDatagramServer class to work at all.  The
  recvfrom() call doesn't return a meaningful client address.  I added
  a comment to this effect.  Maybe it works on other Unix versions.

- The __all__ variable was missing ThreadingMixIn and ForkingMixIn.

- Bumped __version__ to "0.4".

- Added a note about the test suite (to be checked in shortly).
2001-07-10 11:50:09 +00:00
Ka-Ping Yee 285a7e59f3 Add a close_request method to the BaseServer so that the TCPServer class
can close the request connection when it's done handling it.
2001-04-11 04:02:05 +00:00
Skip Montanaro e99d5ea25b added __all__ lists to a number of Python modules
added test script and expected output file as well
this closes patch 103297.
__all__ attributes will be added to other modules without first submitting
a patch, just adding the necessary line to the test script to verify
more-or-less correct implementation.
2001-01-20 19:54:20 +00:00
Guido van Rossum 10b04180a0 Bump __version__; add authorship note for the BaseServer patch. 2001-01-19 16:45:46 +00:00
Guido van Rossum 90cb9067b8 SF Patch #102980, by Luke Kenneth Casson Leighton: BaseServer class
for SocketServer.py (inherited by TCPServer)

Luke wrote:

  The socketserver code, with a little bit of tweaking, can be made
  sufficiently general to service "requests" of any kind, not just by sockets.
  The BaseServer class was created, for example, to poll a table in a MYSQL
  database every 2 seconds. each entry in the table can be allocated a
  Handler which deals with the entry.

  With this patch, using BaseServer and ThreadedServer classes, the creation
  of the server that reads and handles MySQL table entries instead of a
  socket was utterly trivial: about 50 lines of python code.

  You may consider this code to be utterly useless [why would anyone else
  want to do anything like this???] - you are entitled to your opinion. if you
  think so, then think of this: have you considered how to cleanly add SSL to
  the TCPSocketServer? What about using shared memory as the
  communications mechanism for a server, instead of sockets? What about
  communication using files?

  The SocketServer code is extremely good every useful. it's just that as it
  stands, it is tied to sockets, which is not as useful.

I heartily approve of this idea.
2001-01-19 00:44:41 +00:00
Moshe Zadka dd802208a7 Changing allow_reuse_address's default value, and documenting it. 2000-12-13 20:39:22 +00:00
Guido van Rossum 01fed4d4e6 In class StreamRequestHandler, make the default buffering for rfile
and wfile class variables (that the instance can also override).
Change the default for rfile to buffered, because that seems to make a
big difference in performance on some platforms.

An anti-patch is needed to revert the effect in CGIHTTPServer.py which
I'll check in momentarily.
2000-09-01 03:25:14 +00:00
Guido van Rossum e3c7a5fbf5 Add class variable allow_reuse_address in TCPServer -- if nonzero, the
server_bind() method calls setsockopt(SOL_SOCKET, SO_REUSEADDR, 1).
2000-05-09 14:53:29 +00:00
Jeremy Hylton 75260275fe update to use threading module instead of thread. 1999-10-12 16:20:13 +00:00
Guido van Rossum 2ab455a8fa Another patch from Andy Dustman:
"""
Here's a patch for the ForkingMixIn which will prevent the server from
forking itself into the ground. Note: I've tested a very similar patch
(subclassed ForkingMixIn) but not actually tested this one. As you might
surmise, this was done out of necessity...

If the maximum number of children are already running, block while waiting
for a child to exit.
"""

(I added that last sentence as a comment to the code --GvR.)
1999-07-28 21:39:28 +00:00
Guido van Rossum bfadac00ef In collect_children(), put a try-except around os.waitpid() because it
may raise an exception (when there are no children).  Reported by
Andy Dustman.
1999-06-17 15:41:33 +00:00
Guido van Rossum f2f0594587 Laurence Tratt notes that the accept() call in get_request() can fail,
and suggests putting a try/except around the get_request() call in
handle_request().  (All in class TCPServer.)
1999-06-15 22:25:32 +00:00
Guido van Rossum 198e7cac5a Andy Dustman notes that I patched the close() call in the wrong place.
Here's the correct patch!
1999-06-01 18:58:34 +00:00
Guido van Rossum 18659608dc Andy Dustman writes:
I noticed while watching (with lsof) my forking SocketServer app running
that I would get multiple processes listening to the socket. For the most
part, this doesn't hurt things, but if you terminate the server, this can
prevent it from restarting because it cannot bind to the port due to any
running children which also have the socket open. The following one-liner
fixes this.
1999-05-21 16:12:30 +00:00
Guido van Rossum 67a40e814c Patch by Jeff Bauer: a minor change to declare two new
threaded versions of Unix Server classes, using the
ThreadingMixIn class:

    ThreadingUnixStreamServer
    ThreadingUnixDatagramServer
1998-11-30 15:07:01 +00:00
Guido van Rossum fdb3d1a75e Fix typo in docstring: client_request should be client_address.
Noted by Stefan Witzel.
1998-11-16 19:06:30 +00:00
Guido van Rossum 32490824b6 Fixed the UDP server -- this never worked. Ray Loyzaga deserves
credit for complaining about this and for testing these changes.
1998-06-16 02:27:33 +00:00