473,395 Members | 1,348 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Massive unit test vs MySQL

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,

--

- rmgw

<http://www.trustedmedianetworks.com/>

----------------------------------------------------------------------------
Richard Wesley Trusted Media Networks, Inc.

"If we're not careful, we could have a farce on our hands!"
- Tom Stoppard, _On The Razzle_
Jul 18 '05 #1
5 2991
"Richard Wesley" <ha******@trustedmedianetworks.com> schrieb:
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)
Do you p.close() when you are finished? Otherwise the connection opend by
mysql will stay open.
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?

Jul 18 '05 #2
On Thursday 04 September 2003 20:35, Richard Wesley wrote:
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)
Your pipe is still open at this point, and therefore you have a
connection to the database open.
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?


p.close()

-- Neil
Jul 18 '05 #3
In article <bj**********@nntp0.reith.bbc.co.uk>,
Neil Padgen <ne*********@mon.bbc.co.uk> wrote:
On Thursday 04 September 2003 20:35, Richard Wesley wrote:
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)


Your pipe is still open at this point, and therefore you have a
connection to the database open.
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?


p.close()


Yeah, I tried this, but it had no effect.

The odd thing is that the process list cleans up _immediately_ when the
script terminates. Maybe this is some sort of gc problem?

--

- rmgw

<http://www.trustedmedianetworks.com/>

----------------------------------------------------------------------------
Richard Wesley Trusted Media Networks, Inc.

"You're confusing boredom with motivation."
- Sherman in "Sherman's Lagoon"
Jul 18 '05 #4
In article <ha****************************@spectator.sj.sys.u s.xo.net>,
Richard Wesley <ha******@trustedmedianetworks.com> wrote:
In article <bj**********@nntp0.reith.bbc.co.uk>,
Neil Padgen <ne*********@mon.bbc.co.uk> wrote:
On Monday 08 September 2003 22:28, Richard Wesley wrote:
In article <bj**********@nntp0.reith.bbc.co.uk>,
Neil Padgen <ne*********@mon.bbc.co.uk> wrote:

I doubt it - it is generated by mysqldump. And there is no problem
from the command line.


I use exactly the same approach to set up my unit tests, but I have a
different way to get the mysqldump data into the database:

os.system('mysql database_name < dumpfile')


Sadly, this did not work, nor did garbage collection (gc.collect()).

For some reason, mysql is holding onto a whole lot of connections from
my script until the script terminates.


OK, I'm an idiot. It had nothing to do with the reload script. The
connections were from the TestCase subclass I have that instantiates a
connection management object. It appears that the unittest module does
not dispose of the objects it instantiates until the end of the run, so
you need to REALLY clean up in the tearDown method. I discovered this
by making a persistent connection for the reload operation and noticing
that the number of connections still increased.

Thanks to all who responded.

--
Best regards,

Richard Wesley
Co-President, Electric Fish, Inc.
<http://www.electricfish.com/>
(v) +1-206-493-1690x210
(f) +1-206-493-1697
(h) +1-206-632-4536
(m) +1-206-409-4536
Jul 18 '05 #5
>>>>> "Richard" == Richard Wesley <ha******@trustedmedianetworks.com> writes:

Richard> OK, I'm an idiot. It had nothing to do with the reload
Richard> script. The connections were from the TestCase subclass
Richard> I have that instantiates a connection management object.
Richard> It appears that the unittest module does not dispose of
Richard> the objects it instantiates until the end of the run, so
Richard> you need to REALLY clean up in the tearDown method. I
Richard> discovered this by making a persistent connection for the
Richard> reload operation and noticing that the number of
Richard> connections still increased.

Doh! I should have thought of this, as I've had exactly the same
problem in the past.

Thanks for posting your solution.

-- Neil
Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: | last post by:
Hi! I'm looking for unit-testing tools for .NET. Somthing like Java has --> http://www.junit.org regards, gicio
1
by: | last post by:
Hi- I was curious if anyone has had good luck using one of the commercial .NET FTP client libraries to perform massive LIST commands. I have tried various free libraries with no/little success,...
72
by: Jacob | last post by:
I have compiled a set og unit testing recommendations based on my own experience on the concept. Feedback and suggestions for improvements are appreciated: ...
5
by: shuisheng | last post by:
Dear All, I was told that unit test is a powerful tool for progamming. If I am writing a GUI code, is it possible to still using unit test? I have a little experience in using unittest++. But...
176
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write...
1
by: rich_sposato | last post by:
I released version 2.0 of C++ Unit Test Library. You can download it from SourceForget.Net at http://sourceforge.net/projects/cppunittest/ .. I wrote this unit test library because other unit...
6
by: Vyacheslav Maslov | last post by:
Hi all! I have many many many python unit test, which are used for testing some remote web service. The most important issue here is logging of test execution process and result. I strongly...
27
by: brad | last post by:
Does anyone else feel that unittesting is too much work? Not in general, just the official unittest module for small to medium sized projects? It seems easier to write some quick methods that are...
5
by: Ben Finney | last post by:
Howdy all, PEP 299 <URL:http://www.python.org/dev/peps/pep-0299details an enhancement for entry points to Python programs: a module attribute (named '__main__') that will be automatically called...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.