From 29f676c42ea69a22c948406cb2a24142f6e97bc4 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 25 Feb 2017 00:03:43 -0500 Subject: Wrap asyncio.wait into a saner alternative that raises TimeoutError. Fixes #494 --- discord/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'discord/utils.py') diff --git a/discord/utils.py b/discord/utils.py index 5177b1c8..2c5ddc90 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -276,3 +276,10 @@ def async_all(gen): if not elem: return False return True + +@asyncio.coroutine +def sane_wait_for(futures, *, timeout, loop): + done, pending = yield from asyncio.wait(futures, timeout=timeout, loop=loop) + + if len(pending) != 0: + raise asyncio.TimeoutError() -- cgit v1.2.3