[Zope] Z SQL Method, ZMySQLDA, connection pooling, threads, life, the universe, and everything

Dieter Maurer dieter at handshake.de
Sun Aug 24 01:01:46 EDT 2003


Dennis Allison wrote at 2003-8-21 14:01 -0700:
 > ...
 > Mu understanding:  Zope runs multiple threads (up to 7 without recompiling
 > -- it's a ZODB connection limit)

It's not compiled in. Its just a default parameter which can
easily be changed (preferable in a "custom_zodb.py").

 > using the underlying Python threading
 > model.  The scheduling unit for threads is a single HTTP transaction. (IS
 > THIS RIGHT?) Threads are scheduled out of the medusa asyncore by polling
 > select.

"scheduling unit" and "HTTP transaction" are strange terms in this context.

The operating systems schedules the threads and you must
*NOT* expect that there will be no thread switches during
a HTTP request.

 > ...
 > When created, each ZSQL method searches for and binds to one particular
 > RDBMS adaptor. For my pooled connection approach, there'd be only one
 > ZMYSQLDA instance to which all ZSQL Methods would bind.  The ZSQL Method
 > would find the connector by acquisiton (as it does currently) and allow
 > binding to one or another of the predefined virtual connections.  Most
 > of the changes look simple.

MySQL usually does not run in transactional mode.
If it would, you would need to be very careful, not to mix
use of a single connection by different requests!

You would need to lock the connection and release the lock only
after "commit/abort".

 > The ZMySQLDA mechanism will need some significant changes, some of which
 > need to be thread safe.  ZMySQLDA and MySQLdb are thread-safe at level
 > one, that is, threads may share the modules but **not the connections**.

Advice: keep it as it is now!
Just use a single DA instance and let all Z SQL Methods use this DA
instance. That should be sufficient to let MySQL reach its connection
limit (if not, increase the limit).


Dieter



More information about the Zope mailing list