ccs-twistedextensions icon indicating copy to clipboard operation
ccs-twistedextensions copied to clipboard

ConnectionPool.connection grabs a thread even if the ConnectionPool hasn't been started yet

Open macosforgebot opened this issue 11 years ago • 1 comments

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).

macosforgebot avatar Feb 26 '14 19:02 macosforgebot

@wsanchez originally submitted this as comment:1:⁠ticket:840

  • Milestone set to Later

macosforgebot avatar Feb 26 '14 22:02 macosforgebot