[Zope-DB] ZFireBirdDA Multi-threading

W. Robert Kellock sales@creditscore.co.nz
Sun, 14 Apr 2002 21:17:51 +1200


Hello again,

Is someone able to confirm, deny or otherwise explain the following :

Through testing of ZFireBirdDA I have established that when db.DB inherits
from Shared.DC.ZRDB.TM.TM a "certain" level of multi-threading occurs.  My
STUPID_LOG_FILE (see below) shows that transaction 796 starts before
transaction 791 finishes so these transactions aren't serialized.

2002-04-14 T08:26:25 INFO(0) ZFirebirdDA Transaction Registered 791------
2002-04-14 T08:26:25 INFO(0) ZFirebirdDA Inside Existing Transaction
791------
2002-04-14 T08:26:26 INFO(0) ZFirebirdDA Inside Existing Transaction
791------
2002-04-14 T08:26:26 INFO(0) ZFirebirdDA Inside Existing Transaction
791------
2002-04-14 T08:26:29 INFO(0) ZFirebirdDA Inside Existing Transaction
791------
2002-04-14 T08:26:29 INFO(0) ZFirebirdDA Inside Existing Transaction
791------
2002-04-14 T08:26:30 INFO(0) ZFirebirdDA Transaction Registered 796------
2002-04-14 T08:26:30 INFO(0) ZFirebirdDA Inside Existing Transaction
796------
2002-04-14 T08:26:31 INFO(0) ZFirebirdDA Inside Existing Transaction
796------
2002-04-14 T08:26:31 INFO(0) ZFirebirdDA Transaction Finished 791------
2002-04-14 T08:26:31 INFO(0) ZFirebirdDA Inside Existing Transaction
796------
2002-04-14 T08:26:31 INFO(0) ZFirebirdDA Inside Existing
Transaction796------
2002-04-14 T08:26:33 INFO(0) ZFirebirdDA Transaction Finished 796------

Why then are DA's like the Psycopg PostGRESQL DA full of
Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS?  Is it because:

a)  ZODB only allows a small number of threads for database connections and
to get true performance Psycopg allocates a whole lot more connections in
it's C code.

b)  Without the C code containing Py_BEGIN_ALLOW_THREADS and
Py_END_ALLOW_THREADS (the ZFirebirdDA doesn't have any) all method calls
into the C code from Python are serialized anyway despite my log above.

c)  There is some other explanation.

Thanks.

----------------------------------------------------------------------------
---------------------------------
W.Robert Kellock                                    Ph:
+64 3 326 6115
Sales Manager                                        Fax:
+64 3 326 6115
Credit Systems Control Ltd                      Web:
www.creditscore.co.nz
                                              "making decisions easy"
----------------------------------------------------------------------------
---------------------------------

----- Original Message -----
From: "W. Robert Kellock" <sales@creditscore.co.nz>
To: <zope-db@zope.org>
Cc: <phil@harris-family.info>
Sent: Friday, 12 April 2002 09:00
Subject: [Zope-DB] ZFireBirdDA Multi-threading


> Hello,
>
> It appears as though this DA is single threaded.  Can anybody tell me why
> not to thread it using Python, apart from the fact that it will be slower
> than C due to Python's global interpreter lock on threads (I'm a Python
> programmer, not a C programmer and if I'm going to attempt this I want to
> begin the task in Python)?
> --------------------------------------------------------------------------
--
> ---------------------------------
> W.Robert Kellock                                    Ph:
> +64 3 326 6115
> Sales Manager                                        Fax:
> +64 3 326 6115
> Credit Systems Control Ltd                      Web:
> www.creditscore.co.nz
>                                               "making decisions easy"
> --------------------------------------------------------------------------
--
> ---------------------------------
>
>
>
>
>
> _______________________________________________
> Zope-DB mailing list
> Zope-DB@zope.org
> http://lists.zope.org/mailman/listinfo/zope-db