Download FileStream/utils/keepalive.py from AZLABS/telegbot: direct link, hf CLI and curl.
- Browser
- Download file 664 Bytes
-
https://huggingface.co/spaces/AZLABS/telegbot/resolve/main/FileStream/utils/keepalive.py
- Command line
-
hf download hf://spaces/AZLABS/telegbot/FileStream/utils/keepalive.py
-
curl -L -o keepalive.py https://huggingface.co/spaces/AZLABS/telegbot/resolve/main/FileStream/utils/keepalive.py
664 Bytes
| import asyncio | |
| import logging | |
| import aiohttp | |
| import traceback | |
| from FileStream.config import Server | |
| async def ping_server(): | |
| sleep_time = Server.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(Server.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() | |