Refactor code for improved readability and consistency
- Cleaned up whitespace and formatting in various files including http.py, language.py, logger.py, safe_exec.py, and SQL migration scripts. - Consolidated import statements and removed unnecessary blank lines. - Updated logging configuration for better clarity. - Enhanced the safe execution code with improved error handling and logging. - Removed commented-out code and unnecessary variables in backfill_zero_trades.py and other scripts. - Added a pyproject.toml for Ruff and Vulture configuration. - Introduced requirements-dev.txt for development dependencies. - Removed commented-out stock entries in init.sql for cleaner migration scripts.
This commit is contained in:
@@ -1,24 +1,23 @@
|
||||
"""
|
||||
HTTP tool module
|
||||
"""
|
||||
|
||||
import requests
|
||||
from requests.adapters import HTTPAdapter
|
||||
from urllib3.util.retry import Retry
|
||||
|
||||
|
||||
def get_retry_session(
|
||||
retries: int = 3,
|
||||
backoff_factor: float = 0.5,
|
||||
status_forcelist: tuple = (500, 502, 503, 504)
|
||||
retries: int = 3, backoff_factor: float = 0.5, status_forcelist: tuple = (500, 502, 503, 504)
|
||||
) -> requests.Session:
|
||||
"""
|
||||
Get HTTP Session with retry mechanism
|
||||
|
||||
|
||||
Args:
|
||||
retries: number of retries
|
||||
backoff_factor: retry interval factor
|
||||
status_forcelist: HTTP status codes that need to be retried
|
||||
|
||||
|
||||
Returns:
|
||||
Configured Session instance
|
||||
"""
|
||||
@@ -31,11 +30,10 @@ def get_retry_session(
|
||||
status_forcelist=status_forcelist,
|
||||
)
|
||||
adapter = HTTPAdapter(max_retries=retry)
|
||||
session.mount('http://', adapter)
|
||||
session.mount('https://', adapter)
|
||||
session.mount("http://", adapter)
|
||||
session.mount("https://", adapter)
|
||||
return session
|
||||
|
||||
|
||||
# Global shared session
|
||||
global_session = get_retry_session()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user