Add a test for shutdown with hung workers

This commit is contained in:
Kovid Goyal 2022-04-19 10:49:16 +05:30
parent f7b47a72fc
commit fc80be414c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -87,8 +87,6 @@ class FTSAPITest(BaseTest):
cache.close() cache.close()
self.assertFalse(fts.pool.initialized) self.assertFalse(fts.pool.initialized)
# TODO: check shutdown when worker hangs
# check enabling scans pre-exisintg # check enabling scans pre-exisintg
cache = self.new_library() cache = self.new_library()
cache.add_format(1, 'TXTZ', self.make_txtz(b'a test text')) cache.add_format(1, 'TXTZ', self.make_txtz(b'a test text'))
@ -109,7 +107,15 @@ class FTSAPITest(BaseTest):
check(id=2, book=1, format='TXTZ', err_msg='Extracting text from the TXTZ file of size 132 B took too long') check(id=2, book=1, format='TXTZ', err_msg='Extracting text from the TXTZ file of size 132 B took too long')
for w in fts.pool.workers: for w in fts.pool.workers:
w.max_duration = w.__class__.max_duration w.max_duration = w.__class__.max_duration
# check shutdown when workers have hung
for w in fts.pool.workers:
w.code_to_exec = 'import time; time.sleep(100)'
cache.add_format(1, 'TXTZ', self.make_txtz(b'hung worker'))
workers = list(fts.pool.workers)
cache.close() cache.close()
for w in workers:
self.assertFalse(w.is_alive())
def test_fts_triggers(self): def test_fts_triggers(self):
cache = self.init_cache() cache = self.init_cache()