| 206 | |
| 207 | |
| 208 | async def session(): |
| 209 | global sess # pylint: disable=global-statement |
| 210 | time = aiohttp.ClientTimeout(total = None, sock_connect = 10, sock_read = None) # default value is 5 minutes, we need longer for training |
| 211 | sess = aiohttp.ClientSession(timeout = time, base_url = sd_url, auth=auth()) |
| 212 | log.debug({ 'sdapi': 'session created', 'endpoint': sd_url }) |
| 213 | """ |
| 214 | sess = await aiohttp.ClientSession(timeout = timeout).__aenter__() |
| 215 | try: |
| 216 | async with sess.get(url = f'{sd_url}/') as req: |
| 217 | log.debug({ 'sdapi': 'session created', 'endpoint': sd_url }) |
| 218 | except Exception as e: |
| 219 | log.error({ 'sdapi': e }) |
| 220 | await asyncio.sleep(0) |
| 221 | await sess.__aexit__(None, None, None) |
| 222 | sess = None |
| 223 | return sess |
| 224 | """ |
| 225 | return sess |
| 226 | |
| 227 | |
| 228 | async def close(): |