Browse Source

握り潰したエラー表示

main
みてるぞ 1 week ago
parent
commit
d4faff4759
1 changed files with 8 additions and 7 deletions
  1. +8
    -7
      main.py

+ 8
- 7
main.py View File

@@ -295,10 +295,10 @@ async def reconnect_db (
try:
ensure_mysql_alive ()
except Exception as ex:
if getattr (ex, 'args', [None])[0] in (2006, 2013):
safe_reconnect ()
else:
if getattr (ex, 'args', [None])[0] not in (2006, 2013):
raise
print (f"[reconnect_db] { type (ex).__name__ }: { ex }")
safe_reconnect ()


def ensure_mysql_alive (
@@ -314,6 +314,7 @@ def safe_reconnect (
except Exception as ex:
if getattr (ex, 'args', [None])[0] not in (2006, 2013):
raise
print (f"[safe_reconnect] { type (ex).__name__ }: { ex }")


def run_with_mysql_retry (
@@ -327,11 +328,11 @@ def run_with_mysql_retry (
ensure_mysql_alive ()
return fn (*args, **kwargs)
except Exception as ex:
if getattr (ex, 'args', [None])[0] not in (2006, 2013):
raise
last = ex
if getattr (ex, 'args', [None])[0] in (2006, 2013):
safe_reconnect ()
continue
raise
print (f"[run_with_mysql_retry] { type (ex).__name__ }: { ex }")
safe_reconnect ()
if last:
raise last



Loading…
Cancel
Save