[reportlab-users] Re: thread safe ?

Marius Gedminas reportlab-users@reportlab.com
Mon, 29 Jul 2002 16:15:49 +0200

On Mon, Jul 29, 2002 at 09:16:35AM -0400, Jeff Kowalczyk wrote:
> > (7) do not use the same TrueType font for different documents at the
> > same time
> > That's an artifact of dynamic subsetting code in ttfonts.TTFont, and I
> > think I could fix it without much difficulty if there's a need.  The
> > font object would have to maintain different subsets indexed by
> > id(canvas).
> Actually, that may be a limitation Zope users could run into.


> My typical
> Zope use case for reportlab will be to build dynamic forms and reports on
> demand, in response to web form requests.
> Since I'm on the subject, this type of Zope usage should be clear of most of
> the global shared state issues that limit thread-safety, right? I'm not
> really adjusting any global settings, and most of my reports will be simple
> lines and text written to canvas of fixed layout and discrete pages. As soon
> as the PDF is complete, I write it to the Zope Database or the HTTP
> response. Multiple requests to the Zope python product will certainly
> overlap under load, but the canvases will never be shared. Should be OK?

Unfortunately not.

That's exactly what we do here -- generate PDFs according to user
submitted values.  Posting two forms in parallel results in a TTFError
exception for one of them.  I'm now thinking about ways to solve it.  I
am not sure fixing TTFont will be enough, as I remember similair
problems earlier, when we tested reportlab without TTFs.  We didn't see
exceptions, but Acrobat reported one of the PDF files as corrupt.
That's why I didn't bother to make TTF code multithread-safe yet, as I
saw the rest of reportlab wasn't.

The recent message by Andy seemed optimistic -- if it is really safe to
paint on different canvases at the same time without touching global
settings like page sizes/fonts, then it might be worth it to make TTF
thread-safe.  The problems I saw might be due to Platypus, and we no
longer use it here.

Marius Gedminas
#define QUESTION ((bb) || !(bb)) /* Shakespeare */