Client.run now does cleanup when KeyboardInterrupt is encountered.

This commit is contained in:
Rapptz
2015-12-14 16:26:15 -05:00
parent 9137d92f67
commit 6d26d73e24
2 changed files with 57 additions and 26 deletions

View File

@ -175,16 +175,19 @@ class VoiceClient:
@asyncio.coroutine
def keep_alive_handler(self, delay):
while True:
payload = {
'op': 3,
'd': int(time.time())
}
try:
while True:
payload = {
'op': 3,
'd': int(time.time())
}
msg = 'Keeping voice websocket alive with timestamp {}'
log.debug(msg.format(payload['d']))
yield from self.ws.send(utils.to_json(payload))
yield from asyncio.sleep(delay)
msg = 'Keeping voice websocket alive with timestamp {}'
log.debug(msg.format(payload['d']))
yield from self.ws.send(utils.to_json(payload))
yield from asyncio.sleep(delay)
except asyncio.CancelledError:
pass
@asyncio.coroutine
def received_message(self, msg):