mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 18:23:55 +00:00
Set requests default timeout
This commit is contained in:
parent
ddc711ec93
commit
abcdbcfd39
|
@ -10,6 +10,7 @@ from datetime import datetime
|
||||||
from typing import Dict, Optional, List
|
from typing import Dict, Optional, List
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
from requests.adapters import TimeoutSauce
|
||||||
from cachetools import cached, TTLCache
|
from cachetools import cached, TTLCache
|
||||||
|
|
||||||
from freqtrade import __version__, exchange, persistence, rpc, DependencyException, \
|
from freqtrade import __version__, exchange, persistence, rpc, DependencyException, \
|
||||||
|
@ -24,6 +25,23 @@ logger = logging.getLogger('freqtrade')
|
||||||
|
|
||||||
_CONF = {}
|
_CONF = {}
|
||||||
|
|
||||||
|
DEFAULT_TIMEOUT = 120
|
||||||
|
|
||||||
|
|
||||||
|
# Set requests default timeout (fix for #127)
|
||||||
|
class DefaultTimeout(TimeoutSauce):
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
connect = kwargs.get('connect', DEFAULT_TIMEOUT)
|
||||||
|
read = kwargs.get('read', connect)
|
||||||
|
if connect is None:
|
||||||
|
connect = DEFAULT_TIMEOUT
|
||||||
|
if read is None:
|
||||||
|
read = connect
|
||||||
|
super(DefaultTimeout, self).__init__(connect=connect, read=read)
|
||||||
|
|
||||||
|
|
||||||
|
requests.adapters.TimeoutSauce = DefaultTimeout
|
||||||
|
|
||||||
|
|
||||||
def refresh_whitelist(whitelist: List[str]) -> List[str]:
|
def refresh_whitelist(whitelist: List[str]) -> List[str]:
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user