moved sleep function

This commit is contained in:
John Lancaster
2024-10-21 03:25:57 +00:00
parent de496509a9
commit 4b748173c1
2 changed files with 10 additions and 12 deletions

View File

@@ -111,3 +111,10 @@ class AppDaemonRunContext:
return await asyncio.wait_for(coro, timeout)
except asyncio.TimeoutError:
print('Timed out')
async def sleep(self, delay: float):
"""Wrapper function for asyncio.sleep that suppresses and logs a task cancellation"""
try:
await self.run_in_executor(self.stop_event.wait, delay)
except asyncio.CancelledError:
logger.debug('Cancelled during sleep')