Add a TimeoutError if VoiceClient.connect fails.
This commit is contained in:
parent
570ccbf753
commit
701720a0f8
@ -2450,7 +2450,16 @@ class Client:
|
|||||||
}
|
}
|
||||||
|
|
||||||
voice = VoiceClient(**kwargs)
|
voice = VoiceClient(**kwargs)
|
||||||
yield from voice.connect()
|
try:
|
||||||
|
yield from voice.connect()
|
||||||
|
except asyncio.TimeoutError as e:
|
||||||
|
try:
|
||||||
|
yield from voice.disconnect()
|
||||||
|
except:
|
||||||
|
# we don't care if disconnect failed because connection failed
|
||||||
|
pass
|
||||||
|
raise e # re-raise
|
||||||
|
|
||||||
self.connection._add_voice_client(server.id, voice)
|
self.connection._add_voice_client(server.id, voice)
|
||||||
return voice
|
return voice
|
||||||
|
|
||||||
|
@ -553,7 +553,7 @@ class DiscordVoiceWebSocket(websockets.client.WebSocketClientProtocol):
|
|||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def poll_event(self):
|
def poll_event(self):
|
||||||
try:
|
try:
|
||||||
msg = yield from self.recv()
|
msg = yield from asyncio.wait_for(self.recv(), timeout=30.0, loop=self.loop)
|
||||||
yield from self.received_message(json.loads(msg))
|
yield from self.received_message(json.loads(msg))
|
||||||
except websockets.exceptions.ConnectionClosed as e:
|
except websockets.exceptions.ConnectionClosed as e:
|
||||||
raise ConnectionClosed(e) from e
|
raise ConnectionClosed(e) from e
|
||||||
|
Loading…
x
Reference in New Issue
Block a user