On Wed, 15 Mar 2000, Tony McDonald wrote:
If you get Andy Dustmans' MySQLdb Module (http://www.zope.org/Members/adustman/MySQLdb). It's designed to be thread-safe. I've always taken that to mean that if a Zope request does a ZSQL query that uses this module, then if another ZSQL query comes along (in a different Zope thread) then it is *not* blocked until the first query is finished, but runs alongside the first query.
If I'm wrong on this I would *really* appreciate a correction here.
I think that's probably wrong. The thread-safety-ness of MySQLdb is that two threads can share the module. You can't safely share connections, but this is more of a MySQL limitation than a MySQLdb limitation. Of course, you can share connections if you wrap a mutex around it so that only one thread uses it at a time, but it is far better to have multiple connections: Each connection is a seperate MySQL thread on the server side. The old MySQLmodule was probably thread-safe, but not thread-friendly: If you ran a blocking operation (like a query), it would block all the threads (i.e. it did not give up the Python interpreter lock during blocking calls). This apparently causes really bad performance with Zope. I may be deficient on Zope zen, but it seems like you would definitely want to have several connection objects around, perhaps one for each ZSQL Method, so that these can all work in parallel. From a security perspective (i.e. you aren't just paranoid, you know they are out to get you), this may make sense, as you can set up seperate users in MySQL with very specific privileges, so each connection object can only do one thing and can't be hijacked for something else. -- andy dustman | programmer/analyst | comstar.net, inc. telephone: 770.485.6025 / 706.549.7689 | icq: 32922760 | pgp: 0xc72f3f1d "Therefore, sweet knights, if you may doubt your strength or courage, come no further, for death awaits you all, with nasty, big, pointy teeth!"