aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--discord/client.py6
-rw-r--r--discord/ext/commands/bot.py2
-rw-r--r--discord/http.py4
-rw-r--r--discord/state.py9
4 files changed, 12 insertions, 9 deletions
diff --git a/discord/client.py b/discord/client.py
index 8cfe48ef..f8cd4c32 100644
--- a/discord/client.py
+++ b/discord/client.py
@@ -519,8 +519,8 @@ class Client:
self.loop.run_until_complete(self.start(*args, **kwargs))
except KeyboardInterrupt:
self.loop.run_until_complete(self.logout())
- pending = asyncio.Task.all_tasks()
- gathered = asyncio.gather(*pending)
+ pending = asyncio.Task.all_tasks(loop=self.loop)
+ gathered = asyncio.gather(*pending, loop=self.loop)
try:
gathered.cancel()
self.loop.run_until_complete(gathered)
@@ -1393,7 +1393,7 @@ class Client:
to_delete = ret[-100:]
yield from self.delete_messages(to_delete)
count = 0
- yield from asyncio.sleep(1)
+ yield from asyncio.sleep(1, loop=self.loop)
if check(msg):
count += 1
diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py
index 349e5d0d..d23eeb49 100644
--- a/discord/ext/commands/bot.py
+++ b/discord/ext/commands/bot.py
@@ -311,7 +311,7 @@ class Bot(GroupMixin, discord.Client):
if delete_after is not None:
@asyncio.coroutine
def delete():
- yield from asyncio.sleep(delete_after)
+ yield from asyncio.sleep(delete_after, loop=self.loop)
yield from self.delete_message(msg)
discord.compat.create_task(delete(), loop=self.loop)
diff --git a/discord/http.py b/discord/http.py
index fdeaa478..38b7ff8e 100644
--- a/discord/http.py
+++ b/discord/http.py
@@ -120,12 +120,12 @@ class HTTPClient:
# sleep a bit
retry_after = data['retry_after'] / 1000.0
log.info(fmt.format(retry_after, bucket))
- yield from asyncio.sleep(retry_after)
+ yield from asyncio.sleep(retry_after, loop=self.loop)
continue
# we've received a 502, unconditional retry
if r.status == 502 and tries <= 5:
- yield from asyncio.sleep(1 + tries * 2)
+ yield from asyncio.sleep(1 + tries * 2, loop=self.loop)
continue
# the usual error cases
diff --git a/discord/state.py b/discord/state.py
index aed5a746..48a75a47 100644
--- a/discord/state.py
+++ b/discord/state.py
@@ -170,7 +170,7 @@ class ConnectionState:
# this snippet of code is basically waiting 2 seconds
# until the last GUILD_CREATE was sent
launch.set()
- yield from asyncio.sleep(2)
+ yield from asyncio.sleep(2, loop=self.loop)
servers = self._ready_state.servers
@@ -187,7 +187,7 @@ class ConnectionState:
# wait for the chunks
if chunks:
try:
- yield from asyncio.wait(chunks, timeout=len(chunks))
+ yield from asyncio.wait(chunks, timeout=len(chunks), loop=self.loop)
except asyncio.TimeoutError:
log.info('Somehow timed out waiting for chunks.')
@@ -489,7 +489,10 @@ class ConnectionState:
yield from self.chunker(server)
chunks = list(self.chunks_needed(server))
if chunks:
- yield from asyncio.wait(chunks)
+ try:
+ yield from asyncio.wait(chunks, timeout=len(chunks), loop=self.loop)
+ except asyncio.TimeoutError:
+ log.info('Somehow timed out waiting for chunks.')
if unavailable == False:
self.dispatch('server_available', server)