raise takes a long time

Robin Becker robin at reportlab.com
Fri Mar 18 14:30:34 CET 2005


Robin Becker wrote:
> I'm trying to get a handle on a real world problem related to raising an 
> exception. This is in the reportlab SimpleDoctemplate class.
> 
> The following code takes a very long time (>60 seconds) in Python 2.2, 
> 2.3, 2.4, but not in 2.1 (at least on windows).
> 
> raise LayoutError("Flowable %s too large on page %d" % (f.identity(30), 
> self.page))
> 
> However, the supposedly functionally identical code
> 
> ident = f.identity(30)
> raise LayoutError("Flowable %s too large on page %d" % (ident, self.page))
> 
> does not take a long time (<< 1 second). The exception LayoutError is 
> trivial
> class LayoutError(Exception):
>     pass
> 
.....

It seems this problem is caused by the above code being used in a 
cgitb.enabled() environment (in a cgi script). That also explains why it wasn't 
happening in 2.1 as we don't use cgitb in that case.

Moving f out of the cgitb evaluated variables lines allows things to work quickly.

Yet another cgitb problem.
-- 
Robin Becker




More information about the Python-list mailing list