[mod_python] Win32 threading issue

Marc Fiuczynski marcf at becomm.com
Mon May 7 02:41:30 EST 2001


A random shot in the dark...

are you using a multithreaded version of the python interpreter?  If so,
then that might be the cause of your problem.   Somewhere in the mod_python
documentation I read that apache would get confused if you used a
multithreaded version of python.  Check that and please let us (or at least
me) know.

In terms of throughput, you might also try writing a script using "wget" to
measure the number of requests per second you can run (not sure what the
windows equivalent is, or whether you can get it to work with cygwin).

Cheers,
Marc


> -----Original Message-----
> From: Chris Trengove [mailto:trengove at econdata.com.au]
> Sent: Saturday, May 05, 2001 10:08 PM
> To: mod_python at modpython.org
> Subject: [mod_python] Win32 threading issue
> 
> 
> I have been testing the following script on Apache with 
> mod_python (Apache
> 1.13.17, mod_python 2.7.2, Windows 2000). I have been 
> interested in testing
> the possible throughput of this (and more useful scripts), so I have
> another Python script which continually loads this "page".
> 
> from mod_python import apache
> import thread
> 
> def handler(req):
>     req.content_type = "text/plain"
>     req.send_http_header()
>     req.write("%d\n" % thread.get_ident())
>     return apache.OK
> 
> When I run more than one copy of the driver script (in 
> multiple consoles),
> I get behavior indicative of some threading problems. 
> Specifically, some
> connections get "lost", the Apache error log reports various 
> instances of
> "IOError: Write failed...", and I occassionally get an access 
> violation
> inside Apache. Similarly, if I only run one copy of the 
> driver script, and
> just keep hitting the refresh button in a browser, the browser
> occassionally returns TWO numbers, and sometimes reports an error in
> retrieving the data. Note that I have tested my driver 
> program retrieving a
> simple text file, and everything works as expected, so it 
> does not appear
> to be a problem with Apache. (The problem also goes away if I set
> ThreadPerChild to 1 in the Apache configuration.)
> 
> I have also found that, if I comment out the req.write() 
> statement in the
> handler, then there are no problems. From my examination of the
> implementation of the request object, I see that req_write() 
> contains calls
> to Py_BEGIN_ALLOW_THREADS / Py_END_ALLOW_THREADS, whereas
> req_send_http_header() contains no such calls. This suggests 
> to me that
> some thread switching is occurring inside req_write() which 
> is messing with
> the state of the interpreter.
> 
> I would be most grateful if anyone has any information to 
> offer on this.
> 
> Chris Trengove
> 
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://www.modpython.org/mailman/listinfo/mod_python
> 



More information about the Mod_python mailing list