[reportlab-users] thread safe ?

Robin Becker reportlab-users@reportlab.com
Sun, 28 Jul 2002 11:22:57 +0100

In article <3D43B197.B4EBD2B1@rasselstein-hoesch.de>, Dirk Datzert
<dirk.datzert@tks-rasselstein.thyssenkrupp.com> writes
>Hi all,
>I read in several mails that 'reportlab is not thread safe' in
>combination with zope. I'm running zope 2.3.3 with python 2.1.3 and
>reportlab 1.14 on linux 2.4.16
>Can anybody tell me as simple as possible what 'no thread safe' in
>practice means ?
>As far as I know every authenticated user in zope has his own thread.
>Will this be a problem ? 
Dirk, the problem is that reportlab has  global resources which people
might want to change. For example a European might want to set the
default page size to A4 and before his code actuall uses it an American
sets it back to letter.

There are also a large number of font related globals all the
registerFont/Encoding/Face work on global structures. An example is the
TypeFace object. It gets a globally unique name assigned by the user's
code. If I have already defined a face 'myFace' then attempts by others
to do the same will clash.

I advocate a serialisation approach ie restrict access to one thread at
a time which means maintaining a queue of pending requests and forcing a
complete reset. Aaron/Andy seem propose a cgi approach. With multiple
separate processes there's never a problem, but there would be a penalty
caused by starting up a separate python process for each request. 
Robin Becker