summaryrefslogtreecommitdiffstats
path: root/g4f/Provider/retry_provider.py
diff options
context:
space:
mode:
authorTekky <98614666+xtekky@users.noreply.github.com>2023-10-18 12:47:56 +0200
committerGitHub <noreply@github.com>2023-10-18 12:47:56 +0200
commit591e60e74827bd1da3f8e463e4fec48757adc6a9 (patch)
treec8289e9fdcd1fd08d4dd51b9a86b6aa0914fadab /g4f/Provider/retry_provider.py
parent~ (diff)
parentAdd timeout (diff)
downloadgpt4free-591e60e74827bd1da3f8e463e4fec48757adc6a9.tar
gpt4free-591e60e74827bd1da3f8e463e4fec48757adc6a9.tar.gz
gpt4free-591e60e74827bd1da3f8e463e4fec48757adc6a9.tar.bz2
gpt4free-591e60e74827bd1da3f8e463e4fec48757adc6a9.tar.lz
gpt4free-591e60e74827bd1da3f8e463e4fec48757adc6a9.tar.xz
gpt4free-591e60e74827bd1da3f8e463e4fec48757adc6a9.tar.zst
gpt4free-591e60e74827bd1da3f8e463e4fec48757adc6a9.zip
Diffstat (limited to '')
-rw-r--r--g4f/Provider/retry_provider.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/g4f/Provider/retry_provider.py b/g4f/Provider/retry_provider.py
index 94b9b90a..72170756 100644
--- a/g4f/Provider/retry_provider.py
+++ b/g4f/Provider/retry_provider.py
@@ -1,5 +1,6 @@
from __future__ import annotations
+import asyncio
import random
from typing import List, Type, Dict
from ..typing import CreateResult, Messages
@@ -68,7 +69,11 @@ class RetryProvider(AsyncProvider):
self.exceptions: Dict[str, Exception] = {}
for provider in providers:
try:
- return await provider.create_async(model, messages, **kwargs)
+ return await asyncio.wait_for(provider.create_async(model, messages, **kwargs), timeout=60)
+ except asyncio.TimeoutError as e:
+ self.exceptions[provider.__name__] = e
+ if logging:
+ print(f"{provider.__name__}: TimeoutError: {e}")
except Exception as e:
self.exceptions[provider.__name__] = e
if logging: