Two-stage timeouts for Pillar calls

This commit is contained in:
Sybren A. Stüvel 2017-06-13 14:25:37 +02:00
parent 1f40915ac8
commit 82a9dc5226

View File

@ -226,7 +226,11 @@ async def pillar_call(pillar_func, *args, caching=True, **kwargs):
# Use explicit calls to acquire() and release() so that we have more control over # Use explicit calls to acquire() and release() so that we have more control over
# how long we wait and how we handle timeouts. # how long we wait and how we handle timeouts.
try: try:
asyncio.wait_for(pillar_semaphore.acquire(), timeout=60, loop=loop) await asyncio.wait_for(pillar_semaphore.acquire(), timeout=10, loop=loop)
except asyncio.TimeoutError:
log.info('Waiting for semaphore to call %s', pillar_func.__name__)
try:
await asyncio.wait_for(pillar_semaphore.acquire(), timeout=50, loop=loop)
except asyncio.TimeoutError: except asyncio.TimeoutError:
raise RuntimeError('Timeout waiting for Pillar Semaphore!') raise RuntimeError('Timeout waiting for Pillar Semaphore!')