Message3900
When using roundup_server.py with multithreading on MS Windows, HTTP
connections break occasionally, especially when there are many
concurrent requests. Exceptions look like this:
192.168.0.133 - - [08/Oct/2009 09:14:26] "POST /tracker/issue19977
HTTP/1.1" 400 -
EXCEPTION AT Thu Oct 08 09:14:26 2009
Traceback (most recent call last):
File
"C:\Programme\Python25\Lib\site-packages\roundup\scripts\roundup_server.py",
line 108, in run_cgi
self.inner_run_cgi()
File
"C:\Programme\Python25\Lib\site-packages\roundup\scripts\roundup_server.py",
line 284, in inner_run_cgi
c = tracker.Client(tracker, self, env)
File "C:\Programme\Python25\lib\site-packages\roundup\cgi\client.py",
line 186, in __init__
self.form = cgi.FieldStorage(environ=env)
File "C:\Programme\Python25\lib\cgi.py", line 534, in __init__
self.read_multi(environ, keep_blank_values, strict_parsing)
File "C:\Programme\Python25\lib\cgi.py", line 654, in read_multi
environ, keep_blank_values, strict_parsing)
File "C:\Programme\Python25\lib\cgi.py", line 536, in __init__
self.read_single()
File "C:\Programme\Python25\lib\cgi.py", line 669, in read_single
self.read_lines()
File "C:\Programme\Python25\lib\cgi.py", line 691, in read_lines
self.read_lines_to_outerboundary()
File "C:\Programme\Python25\lib\cgi.py", line 719, in
read_lines_to_outerboundary
line = self.fp.readline(1<<16)
File "C:\Programme\Python25\lib\socket.py", line 373, in readline
data = self._sock.recv(self._rbufsize)
AttributeError: 'NoneType' object has no attribute 'recv'
The problem is in the modification of sys.stdin to make the POST data
available to the request handler, as this is not thread-safe. Luckily,
the fix is easy:
Index:
C:/Daten/Projekte/roundup/instances/int1-site-packages-roundup/scripts/roundup_server.py
===================================================================
---
C:/Daten/Projekte/roundup/instances/int1-site-packages-roundup/scripts/roundup_server.py
(revision 1039)
+++
C:/Daten/Projekte/roundup/instances/int1-site-packages-roundup/scripts/roundup_server.py
(revision 1046)
@@ -102,8 +102,6 @@
""" Execute the CGI command. Wrap an innner call in an error
handler so all errors can be caught.
"""
- save_stdin = sys.stdin
- sys.stdin = self.rfile
try:
self.inner_run_cgi()
except client.NotFound:
@@ -140,7 +138,6 @@
# out to the logfile
print 'EXCEPTION AT', ts
traceback.print_exc()
- sys.stdin = save_stdin
do_GET = do_POST = do_HEAD = run_cgi
Index:
C:/Daten/Projekte/roundup/instances/int1-site-packages-roundup/cgi/client.py
===================================================================
---
C:/Daten/Projekte/roundup/instances/int1-site-packages-roundup/cgi/client.py
(revision 1039)
+++
C:/Daten/Projekte/roundup/instances/int1-site-packages-roundup/cgi/client.py
(revision 1046)
@@ -183,7 +183,7 @@
# see if we need to re-parse the environment for the form (eg Zope)
if form is None:
- self.form = cgi.FieldStorage(environ=env)
+ self.form = cgi.FieldStorage(fp=request.rfile, environ=env)
else:
self.form = form
Best regards - Werner Hunger. |
|
Date |
User |
Action |
Args |
2009-10-31 15:02:57 | whunger | set | messageid: <1257001377.84.0.575508492491.issue2550596@psf.upfronthosting.co.za> |
2009-10-31 15:02:57 | whunger | set | recipients:
+ whunger |
2009-10-31 15:02:57 | whunger | link | issue2550596 messages |
2009-10-31 15:02:55 | whunger | create | |
|