#12198 closed defect (fixed)
Python recursion limit
Reported by: | anonymous | Owned by: | Jun Omae |
---|---|---|---|
Priority: | normal | Component: | DefaultCcPlugin |
Severity: | normal | Keywords: | |
Cc: | Trac Release: |
Description
On a system with a lot of components (around 1000), the DefaultCC will cause a Python error (maximum recursion depth exceeded) on the component admin page.
It seems to be related to one of the Genshi functions (render) that DefaultCC uses.
Attachments (1)
Change History (13)
comment:1 follow-up: 2 Changed 10 years ago by
comment:2 Changed 10 years ago by
Replying to rjollos:
Is there any useful info in the stack trace?
Unfortunately it is on a system that I can't cut and paste from.
The Genshi version was 0.6-py2.5
, and Trac was 0.11.6-py2.6
, and I was running DefaultCC 0.2. Although I also observed the same issue on another system that runs the latest version of Trac/Genshi.
The issue is very easy to reproduce. Like I said you just need to add about 1k components (easiest is to just write a simple sqlite script). After that you will see the error when you go to the component admin panel.
According to the traceback, the original call was _dispatch_request
from trac/web/main.py
at line 450, which in turned called dispatch
in the same file at line 227, and then render_template
from trac/web/chrome.py
at line 773. Then after a bunch of other calls, the __call__
function in /genshi/filters/transform.py
will call itself recursively until it crash.
comment:3 Changed 9 years ago by
Here is a workaround that seems to be effective:
-
trunk/defaultcc/admin.py
10 10 # you should have received as part of this distribution. 11 11 # 12 12 13 from genshi import HTML 13 14 from genshi.builder import tag 14 15 from genshi.filters import Transformer 15 16 from trac.core import Component, implements … … 156 157 '/tbody/tr[%d]' % (i + 1)) 157 158 stream |= filter.append(tag.td(default_cc, 158 159 class_='defaultcc')) 160 # Avoid maximum recusion depth errors. 161 if i % 100 == 0: 162 stream = HTML(stream.render()) 159 163 return stream 160 164 161 165 return stream
I'm not familiar with the internals of Genshi, so there may be a better way. Maybe someone else will have a better idea.
The page rendering is very slow though, and I suspect we can't do much better with Genshi. A workaround would be to modify the table using JavaScript, or perhaps optionally, not append Default CC to the table.
Are you still in need of a fix, and are you running Trac 0.11.6?
Changed 9 years ago by
Attachment: | t12198.diff added |
---|
comment:4 Changed 9 years ago by
We shouldn't use many calls of Transformer()
because each call of Transformer()
needs one or more stack. CondFieldsGenshiPlugin has the same issue in #10342.
Instead, we should call Transformer.apply
with custom transformation method only once. Otherwise, directly transform without Tranformer()
like Chrome._strip_accesskeys(). See t12198.diff.
comment:5 Changed 9 years ago by
Status: | new → accepted |
---|
Thanks for the patch! The page renders very fast now. I'll try fixing #10342 as an exercise to better understand the patch :)
comment:11 Changed 9 years ago by
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
comment:12 Changed 9 years ago by
Owner: | changed from Ryan J Ollos to Jun Omae |
---|
Is there any useful info in the stack trace?