Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 3 additions & 18 deletions Framework/deploy_handler/long_poll_handler.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Author: sazid

from typing import Any, Callable
from typing import Any, Callable, Coroutine
import traceback
import asyncio
import random
Expand All @@ -9,7 +9,6 @@
from colorama import Fore
from pathlib import Path
from urllib.parse import urlparse
import requests

from Framework.Utilities import RequestFormatter, ConfigModule, CommonUtil
from Framework.Utilities.RequestFormatter import REQUEST_TIMEOUT
Expand All @@ -30,7 +29,7 @@ class DeployHandler:

def __init__(
self,
on_connect_callback: Callable[[bool], None],
on_connect_callback: Callable[[bool], Coroutine[Any, Any, None]],
response_callback: Callable[[Any], None],
cancel_callback: Callable[[], None],
done_callback: Callable[[], bool],
Expand Down Expand Up @@ -261,9 +260,8 @@ async def run(self, host: str) -> None:
if reconnect:
await asyncio.sleep(random.randint(1, 3))

await self.on_connect_callback(reconnect)

try:
await self.on_connect_callback(reconnect)
reconnect = True
resp = await RequestFormatter.async_request("get", host, timeout=70)
if resp is None:
Expand Down Expand Up @@ -303,19 +301,6 @@ async def run(self, host: str) -> None:
break

reconnect = False
except (
requests.exceptions.ConnectTimeout,
requests.exceptions.ReadTimeout,
requests.exceptions.ConnectionError,
) as e:
# Nginx down, VM down, network issue, docker-compose stopped
if STATE.reconnect_with_credentials is not None:
return None
print_online = True
print(e)
print(Fore.YELLOW + "Retrying after 30s")
await asyncio.sleep(30)

except Exception as e:
if STATE.reconnect_with_credentials is not None:
return None
Expand Down
Loading