Use an Event rather than a sleep to block the worker thread

This commit is contained in:
Kovid Goyal 2017-01-02 08:21:09 +05:30
parent d366bf705c
commit cb8c641e4f

View File

@ -87,7 +87,8 @@ class LoopTest(BaseTest):
server.join() server.join()
self.ae(0, sum(int(w.is_alive()) for w in server.loop.pool.workers)) self.ae(0, sum(int(w.is_alive()) for w in server.loop.pool.workers))
# Test shutdown with hung worker # Test shutdown with hung worker
with TestServer(lambda data:time.sleep(1000000), worker_count=3, shutdown_timeout=0.01, timeout=0.01) as server: block = Event()
with TestServer(lambda data:block.wait(), worker_count=3, shutdown_timeout=0.01, timeout=0.01) as server:
pool = server.loop.pool pool = server.loop.pool
self.ae(3, sum(int(w.is_alive()) for w in pool.workers)) self.ae(3, sum(int(w.is_alive()) for w in pool.workers))
conn = server.connect() conn = server.connect()