Skip to content

Commit

Permalink
hook: allow periodic loop hook to return awaitable coroutine (in simi…
Browse files Browse the repository at this point in the history
…lar style as call)
  • Loading branch information
gauteh authored and pazz committed May 6, 2020
1 parent a1a2436 commit b11aa98
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion alot/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
async def periodic(callable_, period, *args, **kwargs):
while True:
try:
callable_(*args, **kwargs)
t = callable_(*args, **kwargs)
if asyncio.iscoroutine(t):
await t
except Exception as e:
logging.error('error in loop hook %s', str(e))
await asyncio.sleep(period)
Expand Down

0 comments on commit b11aa98

Please sign in to comment.