diff options
| author | Rapptz <[email protected]> | 2017-02-25 00:03:43 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-02-25 00:03:43 -0500 |
| commit | 29f676c42ea69a22c948406cb2a24142f6e97bc4 (patch) | |
| tree | b64b6bfad68a182e448276c5b1c6baac37afa479 /discord/utils.py | |
| parent | Make Guild.large a property instead of an attribute. (diff) | |
| download | discord.py-29f676c42ea69a22c948406cb2a24142f6e97bc4.tar.xz discord.py-29f676c42ea69a22c948406cb2a24142f6e97bc4.zip | |
Wrap asyncio.wait into a saner alternative that raises TimeoutError.
Fixes #494
Diffstat (limited to 'discord/utils.py')
| -rw-r--r-- | discord/utils.py | 7 |
1 files changed, 7 insertions, 0 deletions
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 + +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() |