Hi Gregory,

> Here's the code I'm using, which I believe it set up correctly
> following the docs, but I'm hitting the following errors:
> 
> Error 1:
> 
> Exception exceptions.TypeError: "'NoneType' object is not callable" in
> <bound method PooledDB.__del__ of <DBUtils.PooledDB.PooledDB instance
> at 0x85095cc>> ignored

In which situation do you get this error? I could not reproduce this.

> Error 2:
> 
> ...
> [Tue Nov 20 17:07:23 2007] [error] [client 127.0.0.1]
> OperationalError: (1040, 'Too many connections')
> 
> I set my.conf to have 16 max connections so I don't know why it says
> there are too many since I only gave the pool 10.

There are two reasons why this can happen.

First, make sure you are setting up POOL only one time, globally. Put a 
print statement after the "POOL = " statement and make sure it prints 
only once.

Second, in your POOL object, you don't allow shared connections 
(maxshared = 0), and in your query function you are also requesting 
dedicated connections. Now if you are calling the function very 
frequently from many threads (and the query time is longer than this 
frequency), then the following will happen: The POOL will first give 
away the 4 connections you put in your pool initially. Then there are no 
connections in the pool any more, and DBUtils will request new 
connections from the database until you reach maxconnections=10, at 
which point it will raise an error, because you have set blocking=False.

As a solution, you can set blocking=True, i.e. DBUtils waits until 
another thread has released its connection so it can be reused. This 
will never throw an exception, but will of course not give the best 
performance it you are not allowing for enough connections.

To improve performance, you can increase the max number of connections 
of MySQL to 100 or so, and set maxconnections a little bit lower (so you 
can still log in as an administrator).

A better solution would be to use shared connections (setting maxshared 
to a positive value), but this works only with a database module that 
provides thread-safe connections. MySQLdb will probably not do it (check 
MySQLdb.threadsafety to be sure, it should be > 1 to allow this, if it's 
not, then DBUtils will assume maxshared = 0 no matter how you set it).

You can also try PersistentDB instead of PooledDB and check whether it 
gives better performance for you.

-- Chris

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Webware-devel mailing list
Webware-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-devel

Reply via email to