Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Troubleshoot reportlab heisenbug

Using Django 1.4 / Python 2.7 / reportlab (open source version) to generate pdf.

Things have worked really great up until now. Previously pdf generation (as in http requested returned/downloaded generated pdf file) was on Django 1.3 and not open for public. Have upgraded and made feature free on many pages and now starting to have problems.

I get 'random' problems (as in I see there are exceptions once in a while in logs) but I have never been able to reproduce problems myself (things works most of the time).

What I get is the following type of errors that always happens in pairs

    Exception Value: ParaParser instance has no attribute '_seq'
    Exception Location: /home/tss/lib/python2.7/reportlab-2.5-py2.7-linux-i686.egg/reportlab/platypus/paraparser.py in _complete_parse, line 1061

and then

    Exception Value: 'NoneType' object has no attribute 'close'
    Exception Location: /home/tss/lib/python2.7/reportlab-2.5-py2.7-linux-i686.egg/reportlab/lib/xmllib.py in close, line 521

Given that I am having a hard time reproducing this and not sure if problem on my side or reportlab - I am open for suggestions on how to troubleshoot this (could it be sync issue as in many generating conccurently or just a plain bug or...)???

like image 506
Jens Lundstrom Avatar asked Nov 03 '22 22:11

Jens Lundstrom


1 Answers

Posted this question on the reportlab mailing list and Reportlab is not thread-safe.

So any usage of reportlab where you end up getting intermittent problems and are running in a multithread / web app environment you will get really really strange problems due to this.

Now I need to work out what to replace reportlab with, hmm....

/ Jens

like image 158
Jens Lundstrom Avatar answered Nov 15 '22 06:11

Jens Lundstrom