def test_stop_reaper_thread(self): """Verify that calling stop_reaper will terminate the reaper thread. """ pool = ConnectionPool(MessyConnector, backend='thread') assert pool._reaper.running pool.stop_reaper() for i in xrange(1000): if not pool._reaper.running: return time.sleep(0.01) assert False, 'Reaper thread not terminated in time.'