Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -189,6 +189,14 @@ class MyClient(discord.Client):
|
|
189 |
for part in parts:
|
190 |
await channel.send(part)
|
191 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
async def retry_request(self, func, retries=5, delay=2):
|
193 |
for i in range(retries):
|
194 |
try:
|
@@ -196,11 +204,11 @@ class MyClient(discord.Client):
|
|
196 |
except HTTPError as e:
|
197 |
if e.response.status_code == 503 and i < retries - 1:
|
198 |
logging.warning(f"503 error encountered. Retrying in {delay} seconds...")
|
199 |
-
self.
|
200 |
await asyncio.sleep(delay)
|
201 |
else:
|
202 |
raise
|
203 |
|
204 |
if __name__ == "__main__":
|
205 |
discord_client = MyClient(intents=intents)
|
206 |
-
discord_client.run(os.getenv('DISCORD_TOKEN'))
|
|
|
189 |
for part in parts:
|
190 |
await channel.send(part)
|
191 |
|
192 |
+
def switch_client(self):
|
193 |
+
if self.hf_client == hf_client_primary:
|
194 |
+
self.hf_client = hf_client_secondary
|
195 |
+
logging.info("Switched to secondary client.")
|
196 |
+
else:
|
197 |
+
self.hf_client = hf_client_primary
|
198 |
+
logging.info("Switched back to primary client.")
|
199 |
+
|
200 |
async def retry_request(self, func, retries=5, delay=2):
|
201 |
for i in range(retries):
|
202 |
try:
|
|
|
204 |
except HTTPError as e:
|
205 |
if e.response.status_code == 503 and i < retries - 1:
|
206 |
logging.warning(f"503 error encountered. Retrying in {delay} seconds...")
|
207 |
+
self.switch_client() # 클라이언트 전환
|
208 |
await asyncio.sleep(delay)
|
209 |
else:
|
210 |
raise
|
211 |
|
212 |
if __name__ == "__main__":
|
213 |
discord_client = MyClient(intents=intents)
|
214 |
+
discord_client.run(os.getenv('DISCORD_TOKEN'))
|