Michael Barton
mike at weirdlooking.com
Thu Dec 11 00:55:00 EST 2008
On Dec 10, 2008, at 10:33 PM, "Graham Dumpleton" <graham.dumpleton at gmail.com > wrote: > 2008/12/11 Michael Barton <mike at weirdlooking.com>: >> Yes, sorry. The exceptions I've seen are raised by sendall and recv >> on socket objects inside httplib, which is connected to a service. I >> can reproduce this with a very simple handler like, >> >> from mod_python import apache >> from socket import socket >> >> def handler(req): >> s = socket() >> s.connect(('localhost', 80)) >> s.recv(1024) >> return apache.OK >> >> Make a request to that handler, which will obviously not return any >> time soon. Then hit the server enough times that it reaches >> MaxRequestsPerChild. And, >> >> ... >> File "/home/redbo/test/modpython_handler.py", line 7, in handler\n >> s.recv(1024) >> error: (4, 'Interrupted system call') > > Apache doesn't appear to use SA_RESTART when registering signal > handlers, so yes, it means that system calls interrupted by a signal > will not be restarted. This is quite normal behaviour and typically > programs should be written to detect an EINTR and retry the system > library function call being done if they need to be robust in the face > of such an event. That is, code which would run in an unknown > environment, can't assume system calls will be restarted. > I guess i'm really just frustrated that there's no way to recover a non-fatal exception in httplib without restarting the entire request, which just isn't possible in the case of this case. Maybe I can monkey patch around it or something. It's a python problem though, not a modpython problem. > The EAGAIN error is different and doubtful it is cause by signals. > What EAGAIN means will depend on what system library call is being > used. For recv() it means: > > [EAGAIN] The socket is marked non-blocking, and the > receive > operation would block, or a receive timeout > had been > set, and the timeout expired before data were > received. > It's definitely also happening when apache hits maxrequests. I wonder if this has something to do with python's recv using select to block. I don't have the python source in front of me to see what happens if that select is interrupted. Ah well, thanks for thinking about it. Mike > Graham > >> On Wed, Dec 10, 2008 at 9:19 PM, Graham Dumpleton >> <graham.dumpleton at gmail.com> wrote: >>> Blocking i/o operations against what? Sockets you have created off >>> to >>> something else???? >>> >>> 2008/12/11 Michael Barton <mike at weirdlooking.com>: >>>> Hey list! >>>> >>>> I'm having a problem adapting a mod_python-based app to work with >>>> Apache's worker thread mpm. >>>> >>>> When the process hits MaxRequestsPerChild under a high >>>> concurrency of >>>> requests, blocking i/o operations in other threads on that child >>>> raise >>>> exceptions (mostly EINTR or EAGAIN IOErrors in httplib). >>>> >>>> It looks like system calls are being interrupted by signals Apache >>>> uses to control its children. But that seems like a problem that >>>> would have come up before, and I can't find much by searching the >>>> web >>>> or list archives. >>>> >>>> I figured I'd punt to the list and see if anyone has other >>>> thoughts. >>>> >>>> My setup is: debian, apache 2.2.3, mod_python 3.3.1, python 2.4.4 >>>> >>>> --Mike >>>> _______________________________________________ >>>> Mod_python mailing list >>>> Mod_python at modpython.org >>>> http://mailman.modpython.org/mailman/listinfo/mod_python >>>> >>> >>
|