1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-06 05:12:21 +01:00

improve pool hit rate

This commit is contained in:
J. Nick Koston
2025-09-02 16:12:59 -05:00
parent b009a0f967
commit e0e8a982d5
2 changed files with 22 additions and 22 deletions

View File

@@ -118,33 +118,33 @@ async def test_scheduler_pool(
try:
# Phase 1: Component lifecycle
client.execute_service(phase_services[1], {})
await asyncio.wait_for(phase_futures[1], timeout=3.0)
await asyncio.sleep(0.5) # Let timeouts complete
await asyncio.wait_for(phase_futures[1], timeout=1.0)
await asyncio.sleep(0.05) # Let timeouts complete
# Phase 2: Sensor polling
client.execute_service(phase_services[2], {})
await asyncio.wait_for(phase_futures[2], timeout=3.0)
await asyncio.sleep(1.0) # Let intervals run a bit
await asyncio.wait_for(phase_futures[2], timeout=1.0)
await asyncio.sleep(0.1) # Let intervals run a bit
# Phase 3: Communication patterns
client.execute_service(phase_services[3], {})
await asyncio.wait_for(phase_futures[3], timeout=3.0)
await asyncio.sleep(1.0) # Let heartbeat run
await asyncio.wait_for(phase_futures[3], timeout=1.0)
await asyncio.sleep(0.1) # Let heartbeat run
# Phase 4: Defer patterns
client.execute_service(phase_services[4], {})
await asyncio.wait_for(phase_futures[4], timeout=3.0)
await asyncio.sleep(2.0) # Let everything settle and recycle
await asyncio.wait_for(phase_futures[4], timeout=1.0)
await asyncio.sleep(0.2) # Let everything settle and recycle
# Phase 5: Pool reuse verification
client.execute_service(phase_services[5], {})
await asyncio.wait_for(phase_futures[5], timeout=3.0)
await asyncio.sleep(1.0) # Let Phase 5 timeouts complete and recycle
await asyncio.wait_for(phase_futures[5], timeout=1.0)
await asyncio.sleep(0.1) # Let Phase 5 timeouts complete and recycle
# Phase 6: Full pool reuse verification
client.execute_service(phase_services[6], {})
await asyncio.wait_for(phase_futures[6], timeout=3.0)
await asyncio.sleep(1.0) # Let Phase 6 timeouts complete
await asyncio.wait_for(phase_futures[6], timeout=1.0)
await asyncio.sleep(0.1) # Let Phase 6 timeouts complete
# Complete test
client.execute_service(complete_service, {})