TestAutoScaling wait for process to stop

This commit is contained in:
Seth Foster 2023-03-10 15:51:28 -05:00
parent 5a3900a927
commit 160508c907

View File

@ -235,6 +235,7 @@ class TestAutoScaling:
assert len(self.pool) == 10
assert self.pool.workers[0].messages_sent == 2
@pytest.mark.timeout(20)
def test_lost_worker_autoscale(self):
# if a worker exits, it should be replaced automatically up to min_workers
self.pool.init_workers(ResultWriter().work_loop, multiprocessing.Queue())
@ -243,8 +244,8 @@ class TestAutoScaling:
assert len(self.pool) == 2
assert not self.pool.should_grow
alive_pid = self.pool.workers[1].pid
self.pool.workers[0].process.terminate()
time.sleep(2) # wait a moment for sigterm
self.pool.workers[0].process.kill()
self.pool.workers[0].process.join() # waits for process to full terminate
# clean up and the dead worker
self.pool.cleanup()