Spaces:
Running
Running
File size: 688 Bytes
b00d2c6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#Thanks @DeletedFromEarth for helping in this journey
import asyncio
import logging
import aiohttp
import traceback
from info import *
async def ping_server():
sleep_time = PING_INTERVAL
while True:
await asyncio.sleep(sleep_time)
try:
async with aiohttp.ClientSession(
timeout=aiohttp.ClientTimeout(total=10)
) as session:
async with session.get(URL) as resp:
logging.info("Pinged server with response: {}".format(resp.status))
except TimeoutError:
logging.warning("Couldn't connect to the site URL..!")
except Exception:
traceback.print_exc()
|