From 82a9dc522631f62f7ba4266c742e8f4d47ac3395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 13 Jun 2017 14:25:37 +0200 Subject: [PATCH] Two-stage timeouts for Pillar calls --- blender_cloud/pillar.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/blender_cloud/pillar.py b/blender_cloud/pillar.py index 868fcd2..43d98c6 100755 --- a/blender_cloud/pillar.py +++ b/blender_cloud/pillar.py @@ -226,9 +226,13 @@ async def pillar_call(pillar_func, *args, caching=True, **kwargs): # Use explicit calls to acquire() and release() so that we have more control over # how long we wait and how we handle timeouts. 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: - raise RuntimeError('Timeout waiting for Pillar Semaphore!') + 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: + raise RuntimeError('Timeout waiting for Pillar Semaphore!') try: return await loop.run_in_executor(None, partial)