Massive unit test vs MySQL

Andy Todd andy47 at halfcooked.com
Fri Sep 5 16:57:40 CEST 2003


Richard Wesley wrote:
> I don't know if this is really a Python question of a MySQL question, 
> but i am hopen that there is enough overlap that someone can help me ;-)
> 
> I have a unit test suite for our server that loads a clean database 
> image for many of the tests.  I use
> 
> p = os.popen('mysql -u uid -ppassword mydatabase', 'w')
> p.write(sql_commands)
> 
> to load the database.
> 
> While the tests are running, I find that mysql has a growing number of 
> "Sleeping" threads in the 'show processlist' table.  Towards the end of 
> the test suite, the database loads start to fail with a MySQL error of 
> "ERROR 1040: Too many connections".
> 
> So my question would be, is there any way to shut down the child process 
> so that MySQL notices and cleans up after itself before it runs out of 
> threads?
> 
> TIA,
> 

As you aren't using the Python MySQL module and just piping commands to 
an OS process then its likely to be a MySQL problem.

However, its hard to figure out what you're doing wrong because you 
don't tell us what you are doing. What, for instance, are the contents 
of 'sql_commands'?

Generally, if a database complains about too many connections it is 
because you are explicitly (and repeatedly) connecting to it and then 
not releasing those connections when you are finished with them.

Then again, if you are just loading test data into a clean database I'd 
suggest using some of the MySQL utilities to back up and restore and not 
writing your own code. Have a look at mysqldump 
(http://www.mysql.com/doc/en/mysqldump.html)

Regards,
Andy
-- 
--------------------------------------------------------------------------------
 From the desk of Andrew J Todd esq - http://www.halfcooked.com/







More information about the Python-list mailing list