t.p.threadpool leaks threads
[email protected] Sun, 21 Feb 2010 03:23:17 -0000
| Newsgroups | gmane.comp.python.twisted.bugs |
|---|---|
| Message-ID | <[email protected]> |
New submission from dustin <None>:
My project is using sqlite3 via adbapi, so the unit tests create a lot of "test" databases that are immediately destroyed.
These tests started failing with resource-exhaustion errors -- !MemoryError or "can't start new thread" -- so I went hunting for a thread leak. I narrowed the search down to adbapi, and then to the threadpool. This is in Twisted-9.0.0. The failing test is
http://gist.github.com/310039
{{{
import threading
from twisted.python import threadpool
from twisted.internet import threads
from twisted.trial import unittest
class t(unittest.TestCase):
def setUp(self):
self.pool = threadpool.ThreadPool(3, 5)
self.pool.start()
def tearDown(self):
print list(threading.enumerate())
def testit(self):
from twisted.internet import reactor
return threads.deferToThreadPool(reactor, self.pool, lambda : True)
def testit2(self):
return self.testit()
def testit3(self):
return self.testit()
def testit4(self):
return self.testit()
def testit5(self):
return self.testit()
def testit6(self):
return self.testit()
def testit7(self):
return self.testit()
def testit8(self):
return self.testit()
}}}
This shows that the number of extant threads is increasing by 3 for each test.
I've seen this under Python 2.4-2.6. I've only tried Twisted-9.0.0, so I don't know if this is a regression or not.
----------
Type : defect
Component: core
Keywords :
Priority : normal
Nosy :
----------
http://twistedmatrix.com/trac/ticket/4284