Edgewall Software
Modify

Opened 18 years ago

Closed 15 years ago

Last modified 15 years ago

#3043 closed defect (fixed)

Intermittent error due to `environ` being `None` in TracStandalone

Reported by: Christian Boos Owned by: Christian Boos
Priority: high Milestone: 0.11.5
Component: web frontend/tracd Version: devel
Severity: major Keywords: wsgi python23
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

This happens from time to times, either when reading or writing to environ. Here's a backtrace obtained when trying to write into environ, which happens to be None.

localhost - - [16/Apr/2006 12:35:15] "GET /devel/chrome/common/trac_banner.png HTTP/1.1" 200 -
localhost - - [16/Apr/2006 12:35:15] "GET /devel/chrome/common/trac_logo_mini.png HTTP/1.1" 200 -
localhost - - [16/Apr/2006 12:35:15] "GET /devel/chrome/common/dots.gif HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 1553)
Traceback (most recent call last):
  File "C:\Program Files\ActiveState\Python-2.4\lib\SocketServer.py", line 463, in process_request_thread
    self.finish_request(request, client_address)
  File "C:\Program Files\ActiveState\Python-2.4\lib\SocketServer.py", line 254, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Program Files\ActiveState\Python-2.4\lib\SocketServer.py", line 521, in __init__
localhost - - [16/Apr/2006 12:35:15] "GET /devel/chrome/common/trac.ico HTTP/1.1" 200 -
    self.handle()
  File "C:\Program Files\ActiveState\Python-2.4\lib\BaseHTTPServer.py", line 316, in handle
    self.handle_one_request()
  File "C:\Workspace\install\lib\python\trac\devel\lib\site-packages\trac\web\wsgi.py", line 173, in handle_one_request
localhost - - [16/Apr/2006 12:35:15] "GET /devel/chrome/common/topbar_gradient2.png HTTP/1.1" 200 -
    gateway = self.server.gateway(self, environ)
  File "C:\Workspace\install\lib\python\trac\devel\lib\site-packages\trac\web\wsgi.py", line 187, in __init__
    _ErrorsWrapper(lambda x: handler.log_error('%s', x)))
  File "C:\Workspace\install\lib\python\trac\devel\lib\site-packages\trac\web\wsgi.py", line 69, in __init__
    environ['wsgi.version'] = self.wsgi_version
TypeError: object does not support item assignment
----------------------------------------
localhost - - [16/Apr/2006 12:35:15] "GET /devel/chrome/common/asc.png HTTP/1.1" 200 -
localhost - - [16/Apr/2006 12:35:15] "GET /devel/chrome/common/folder.png HTTP/1.1" 200 -
localhost - - [16/Apr/2006 12:35:15] "GET /devel/chrome/common/parent.png HTTP/1.1" 200 -

This Python 2.4.2, on Windows (but happened also with 2.3.5).

After some code inspection, it seems that in WSGIRequestHandler.setup_environ, there's this code path:

        self.raw_requestline = self.rfile.readline()
        if not self.parse_request(): # An error code has been sent, just exit
            self.close_connection = 1
            return

which is certainly the reason for the above error. I'm not sure what's going on here, as neither raw_requestline, nor close_connection seems to be used anywhere else…

Attachments (0)

Change History (9)

comment:1 by Christian Boos, 18 years ago

Milestone: 0.10
Severity: minormajor

Just had that again, this time on the main resource (the GET of a Wiki page, immediately after a preview or a save).

localhost - - [05/Jun/2006 17:46:07] "POST /devel/wiki/TracDev/UnicodeGuidelines HTTP/1.1" 3
5:46:13 PM Trac[api] DEBUG: Updating wiki page index
localhost - - [05/Jun/2006 17:46:13] "GET /devel/wiki/TracDev/UnicodeGuidelines HTTP/1.1" 20
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 3793)
Traceback (most recent call last):
...
5:46:27 PM Trac[api] DEBUG: Updating wiki page index
    environ['wsgi.version'] = self.wsgi_version
TypeError: object does not support item assignment

That was with tracd r3361/win. I had the problem while testing Trac with IE/Win and it was reproductible quite consistently, as the GET succeeded only once in about 20 preview attempts… I was however not able to reproduce the issue using either Firefox or Opera…

Editing smaller pages with IE/Win was OK though (the content of the above page was the same that the TracDev/UnicodeGuidelines here)

comment:2 by Christian Boos, 18 years ago

Milestone: 0.100.11

Well, the problem is still there, but I think this can wait for 0.10.x. Switching it temporarily to 0.11.

comment:3 by Christian Boos, 17 years ago

Keywords: iexplorer added
Priority: normallow

The problem is still there for 0.11, but is quite difficult to trigger. I'm 95% sure I was using IExplorer when I got this backtrace:

127.0.0.1 - - [13/Jun/2007 14:18:53] "GET /devel/timeline HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 2144)
Traceback (most recent call last):
  File "C:\Program Files\ActiveState\Python-2.4\lib\SocketServer.py", line 465, in process_request_thread
    self.finish_request(request, client_address)
  File "C:\Program Files\ActiveState\Python-2.4\lib\SocketServer.py", line 256, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Program Files\ActiveState\Python-2.4\lib\SocketServer.py", line 523, in __init__
    self.handle()
  File "C:\Program Files\ActiveState\Python-2.4\lib\BaseHTTPServer.py", line 316, in handle
    self.handle_one_request()
  File "C:\Workspace\src\trac\branches\trunk\trac\web\wsgi.py", line 173, in handle_one_request
    gateway = self.server.gateway(self, environ)
  File "C:\Workspace\src\trac\branches\trunk\trac\web\wsgi.py", line 187, in __init__
    _ErrorsWrapper(lambda x: handler.log_error('%s', x)))
  File "C:\Workspace\src\trac\branches\trunk\trac\web\wsgi.py", line 69, in __init__
    environ['wsgi.version'] = self.wsgi_version
TypeError: object does not support item assignment
----------------------------------------

comment:4 by Christian Boos, 17 years ago

Keywords: iexplorer removed
Priority: lownormal

Ok, IExplorer has nothing to do here - I just got it using Firefox:

$ PATH=/C/Program\ Files/PostgreSQL/8.1/bin:$PATH python trac/web/standalone.py -p 8000 C:/TEMP/tractest
Server starting in PID 6108.
Serving on 0.0.0.0:8000 view at http://127.0.0.1:8000/
127.0.0.1 - - [10/Jul/2007 11:12:44] "GET /tractest HTTP/1.1" 200 -
127.0.0.1 - - [10/Jul/2007 11:12:44] "GET /tractest/chrome/common/css/trac.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jul/2007 11:12:44] "GET /tractest/chrome/common/css/wiki.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jul/2007 11:12:44] "GET /tractest/chrome/common/css/code.css HTTP/1.1" 304 -
127.0.0.1 - - [10/Jul/2007 11:12:44] "GET /tractest/chrome/common/js/jquery.js HTTP/1.1" 304 -
127.0.0.1 - - [10/Jul/2007 11:12:45] "GET /tractest/chrome/common/js/trac.js HTTP/1.1" 304 -
127.0.0.1 - - [10/Jul/2007 11:12:45] "GET /tractest/chrome/common/js/search.js HTTP/1.1" 304 -
127.0.0.1 - - [10/Jul/2007 11:12:45] "GET /tractest/chrome/common/trac_banner.png HTTP/1.1" 304 -
127.0.0.1 - - [10/Jul/2007 11:12:45] "GET /tractest/chrome/common/topbar_gradient.png HTTP/1.1" 304 -
127.0.0.1 - - [10/Jul/2007 11:12:45] "GET /tractest/chrome/common/trac_logo_mini.png HTTP/1.1" 304 -
127.0.0.1 - - [10/Jul/2007 11:12:45] "GET /tractest/chrome/common/topbar_gradient2.png HTTP/1.1" 304 -
127.0.0.1 - - [10/Jul/2007 11:12:45] "GET /tractest/chrome/common/dots.gif HTTP/1.1" 304 -
127.0.0.1 - - [10/Jul/2007 11:12:45] "GET /tractest/chrome/common/extlink.gif HTTP/1.1" 304 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 1096)
Traceback (most recent call last):
  File "C:\Program Files\ActiveState\Python-2.4\lib\SocketServer.py", line 465, in process_request_thread
    self.finish_request(request, client_address)
  File "C:\Program Files\ActiveState\Python-2.4\lib\SocketServer.py", line 256, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Program Files\ActiveState\Python-2.4\lib\SocketServer.py", line 523, in __init__
    self.handle()
  File "C:\Program Files\ActiveState\Python-2.4\lib\BaseHTTPServer.py", line 316, in handle
    self.handle_one_request()
  File "C:\Workspace\src\trac\branches\trunk\trac\web\wsgi.py", line 173, in handle_one_request
    gateway = self.server.gateway(self, environ)
  File "C:\Workspace\src\trac\branches\trunk\trac\web\wsgi.py", line 187, in __init__
    _ErrorsWrapper(lambda x: handler.log_error('%s', x)))
  File "C:\Workspace\src\trac\branches\trunk\trac\web\wsgi.py", line 69, in __init__
    environ['wsgi.version'] = self.wsgi_version
TypeError: object does not support item assignment
----------------------------------------
127.0.0.1 - - [10/Jul/2007 11:13:03] "GET /tractest/browser HTTP/1.1" 200 -

comment:5 by Christian Boos, 16 years ago

Priority: normalhigh

… and it also happens with tracd on Linux, Firefox client, with recent trunk:

172.25.16.21 - - [26/Nov/2007 10:31:27] "GET /env/changeset/4169?annotate=trunk%2Ftrac%2Fweb%2Fmain.py HTTP/1.1" 200 -
----------------------------------------
Exception happened during processing of request from ('172.25.16.21', 1963)
Traceback (most recent call last):
  File "/opt/python-2.4.4/lib/python2.4/SocketServer.py", line 463, in process_request_thread
    self.finish_request(request, client_address)
  File "/opt/python-2.4.4/lib/python2.4/SocketServer.py", line 254, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/opt/python-2.4.4/lib/python2.4/SocketServer.py", line 521, in __init__
    self.handle()
  File "/opt/python-2.4.4/lib/python2.4/BaseHTTPServer.py", line 316, in handle
    self.handle_one_request()
  File "/opt/python-2.4.4/lib/python2.4/site-packages/Trac-0.11dev_r6191-py2.4.egg/trac/web/wsgi.py", line 173, in handle_one_request
    gateway = self.server.gateway(self, environ)
  File "/opt/python-2.4.4/lib/python2.4/site-packages/Trac-0.11dev_r6191-py2.4.egg/trac/web/wsgi.py", line 187, in __init__
    _ErrorsWrapper(lambda x: handler.log_error('%s', x)))
  File "/opt/python-2.4.4/lib/python2.4/site-packages/Trac-0.11dev_r6191-py2.4.egg/trac/web/wsgi.py", line 69, in __init__
    environ['wsgi.version'] = self.wsgi_version
TypeError: object does not support item assignment
----------------------------------------

comment:6 by digisign.uk@…, 16 years ago

Is there a solution or a cause for this? Came from unknown address. Below is my system list.

Windows 2003
Trac:  	0.11dev-r6753
Python: 	2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)]
setuptools: 	0.6c8
SQLite: 	3.5.2
pysqlite: 	2.4.1
Genshi: 	0.4.4
Subversion: 	1.4.5 (r25188)
jQuery:	1.2.3
('84.14.204.38', 42930)
Traceback (most recent call last):
  File "C:\Python24\lib\SocketServer.py", line 463, in process_request_thread
    self.finish_request(request, client_address)
  File "C:\Python24\lib\SocketServer.py", line 254, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Python24\lib\SocketServer.py", line 521, in __init__
    self.handle()
  File "C:\Python24\lib\BaseHTTPServer.py", line 316, in handle
    self.handle_one_request()
  File "c:\python24\lib\site-packages\Trac-0.11dev_r6753-py2.4.egg\trac\web\wsgi.py", line 173, in handle_one_request
    gateway = self.server.gateway(self, environ)
  File "c:\python24\lib\site-packages\Trac-0.11dev_r6753-py2.4.egg\trac\web\wsgi.py", line 187, in __init__
    _ErrorsWrapper(lambda x: handler.log_error('%s', x)))
  File "c:\python24\lib\site-packages\Trac-0.11dev_r6753-py2.4.egg\trac\web\wsgi.py", line 69, in __init__
    environ['wsgi.version'] = self.wsgi_version
TypeError: object does not support item assignment

comment:7 by Christian Boos, 15 years ago

Milestone: 0.11-retriage0.11.5
Owner: changed from Jonas Borgström to Christian Boos

Move high prio tickets from 0.11-triage to next maintenance release.

comment:8 by Christian Boos, 15 years ago

Resolution: fixed
Status: newclosed

Fixed by r8080.

There are a couple of situations where the request can't be properly read because the connection with the client was interrupted, like when editing big wiki pages with IE, the use case which prompted this ticket, or more generally when tracd uses HTTP/1.1 and Keep-Alive connections (#8020). When this happens, setup_environ() returns None and we should simply stop there and avoid trying to process the request further.

comment:9 by Christian Boos, 15 years ago

Keywords: python23 added

Note that the fix doesn't work with Python 2.3 (see r8128).

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Christian Boos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Christian Boos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.