Properly propagate loop. Fixes #420.
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user