ccs-twistedextensions
ccs-twistedextensions copied to clipboard
ConnectionPool.connection grabs a thread even if the ConnectionPool hasn't been started yet
exarkun@… originally submitted this as ticket:840
This example hangs indefinitely:
from twext.enterprise.adbapi2 import ConnectionPool
from twisted.internet import reactor
def connect(*args, **kw):
raise NotImplementedError()
pool = ConnectionPool(connect)
connection = pool.connection()
reactor.callWhenRunning(reactor.stop)
reactor.run()
This is because ConnectionPool.connection creates and starts a ThreadHolder which starts a worker thread in the reactor's thread pool.
The ThreadHolder would probably get stopped (releasing the thread) if the ConnectionPool had startService and then stopService called on it. I think it's a bug that a thread gets grabbed before the ConnectionPool is started (or, as in this case, even if the ConnectionPool is never started).