Revert "fix: roll back to unique session per request"
This reverts commit 5a78ca97bd1eeeb8de6d96a18aa9f1a2d51869b6.
This commit is contained in:
parent
4927d81e73
commit
b8dded1535
@ -28,27 +28,27 @@ from aiohttp import web, ClientSession, ClientError, ClientTimeout
|
||||
import atexit
|
||||
|
||||
# Global session
|
||||
# client_session = None
|
||||
client_session = None
|
||||
|
||||
# def create_client_session():
|
||||
# global client_session
|
||||
# if client_session is None:
|
||||
# client_session = aiohttp.ClientSession()
|
||||
|
||||
# async def ensure_client_session():
|
||||
# global client_session
|
||||
# if client_session is None:
|
||||
# client_session = aiohttp.ClientSession()
|
||||
async def ensure_client_session():
|
||||
global client_session
|
||||
if client_session is None:
|
||||
client_session = aiohttp.ClientSession()
|
||||
|
||||
# async def cleanup():
|
||||
# global client_session
|
||||
# if client_session:
|
||||
# await client_session.close()
|
||||
async def cleanup():
|
||||
global client_session
|
||||
if client_session:
|
||||
await client_session.close()
|
||||
|
||||
def exit_handler():
|
||||
print("Exiting the application. Initiating cleanup...")
|
||||
# loop = asyncio.get_event_loop()
|
||||
# loop.run_until_complete(cleanup())
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(cleanup())
|
||||
|
||||
atexit.register(exit_handler)
|
||||
|
||||
@ -60,9 +60,8 @@ print(f"max_retries: {max_retries}, retry_delay_multiplier: {retry_delay_multipl
|
||||
import time
|
||||
|
||||
async def async_request_with_retry(method, url, disable_timeout=False, token=None, **kwargs):
|
||||
# global client_session
|
||||
# await ensure_client_session()
|
||||
async with aiohttp.ClientSession() as client_session:
|
||||
global client_session
|
||||
await ensure_client_session()
|
||||
retry_delay = 1 # Start with 1 second delay
|
||||
initial_timeout = 5 # 5 seconds timeout for the initial connection
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user