Skip to content

Commit

Permalink
Update ECODFF to 2.0.27
Browse files Browse the repository at this point in the history
Retry connecting only for few cases
  • Loading branch information
hawkeye116477 committed Sep 18, 2024
1 parent d256404 commit 70594a6
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions scripts/ECODFF.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import git

# Version number
SCRIPT_VERSION = "2.0.26"
SCRIPT_VERSION = "2.0.27"

# Parse arguments
parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -308,21 +308,24 @@ async def get_status_code(session: aiohttp.ClientSession, url: str, limit):
status_code = 200
except (aiohttp.ClientOSError, asyncio.TimeoutError, aiohttp.ClientConnectorError, aiohttp.ServerDisconnectedError) as ex:
print(f"{ex} ({url})")
await asyncio.sleep(1)
try:
print(f"Checking the status of {url} again...")
resp = await session.head(f"http://{url}", allow_redirects=False)
status_code = resp.status
if status_code in (301, 302, 307, 308):
location = str(resp).split("Location': \'")[1].split("\'")[0]
if url in location:
status_code = 200
except Exception as ex2:
print(f"{ex2} ({url})")
if "reset by peer" not in str(ex2):
status_code = "000"
else:
status_code = "200"
if type(ex).__name__ == aiohttp.ServerDisconnectedError or "reset by peer" in str(ex):
try:
await asyncio.sleep(1)
print(f"Checking the status of {url} again...")
resp = await session.head(f"http://{url}", allow_redirects=False)
status_code = resp.status
if status_code in (301, 302, 307, 308):
location = str(resp).split("Location': \'")[1].split("\'")[0]
if url in location:
status_code = 200
except Exception as ex2:
print(f"{ex2} ({url})")
if "reset by peer" not in str(ex2):
status_code = "000"
else:
status_code = "200"
else:
status_code = "000"
finally:
result = ""
if "status_code" in locals():
Expand Down

0 comments on commit 70594a6

Please sign in to comment.