(timer): Add extra timeout to connect.
This commit is contained in:
@@ -481,14 +481,13 @@ class Timer:
|
|||||||
async with self.lguild.voice_lock:
|
async with self.lguild.voice_lock:
|
||||||
try:
|
try:
|
||||||
if self.guild.voice_client:
|
if self.guild.voice_client:
|
||||||
print("Disconnecting")
|
|
||||||
await self.guild.voice_client.disconnect(force=True)
|
await self.guild.voice_client.disconnect(force=True)
|
||||||
print("Disconnected")
|
|
||||||
alert_file = focus_alert_path if stage.focused else break_alert_path
|
alert_file = focus_alert_path if stage.focused else break_alert_path
|
||||||
try:
|
try:
|
||||||
print("Connecting")
|
voice_client = await asyncio.wait_for(
|
||||||
voice_client = await self.channel.connect(timeout=60, reconnect=False)
|
self.channel.connect(timeout=30, reconnect=False),
|
||||||
print("Connected")
|
timeout=60
|
||||||
|
)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
logger.warning(f"Timed out while connecting to voice channel in timer {self!r}")
|
logger.warning(f"Timed out while connecting to voice channel in timer {self!r}")
|
||||||
return
|
return
|
||||||
@@ -515,13 +514,18 @@ class Timer:
|
|||||||
_, pending = await asyncio.wait([sleep_task, wait_task], return_when=asyncio.FIRST_COMPLETED)
|
_, pending = await asyncio.wait([sleep_task, wait_task], return_when=asyncio.FIRST_COMPLETED)
|
||||||
for task in pending:
|
for task in pending:
|
||||||
task.cancel()
|
task.cancel()
|
||||||
|
except asyncio.TimeoutError:
|
||||||
if self.guild and self.guild.voice_client:
|
logger.warning(
|
||||||
await self.guild.voice_client.disconnect(force=True)
|
f"Timed out while sending voice alert for timer {self!r}",
|
||||||
|
exc_info=True
|
||||||
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
f"Exception occurred while playing voice alert for timer {self!r}"
|
f"Exception occurred while playing voice alert for timer {self!r}"
|
||||||
)
|
)
|
||||||
|
finally:
|
||||||
|
if self.guild and self.guild.voice_client:
|
||||||
|
await self.guild.voice_client.disconnect(force=True)
|
||||||
|
|
||||||
def stageline(self, stage: Stage):
|
def stageline(self, stage: Stage):
|
||||||
t = self.bot.translator.t
|
t = self.bot.translator.t
|
||||||
|
|||||||
Reference in New Issue
Block a user