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: try:
ensure_mysql_alive () ensure_mysql_alive ()
except Exception as ex: 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 raise
print (f"[reconnect_db] { type (ex).__name__ }: { ex }")
safe_reconnect ()




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




def run_with_mysql_retry ( def run_with_mysql_retry (
@@ -327,11 +328,11 @@ def run_with_mysql_retry (
ensure_mysql_alive () ensure_mysql_alive ()
return fn (*args, **kwargs) return fn (*args, **kwargs)
except Exception as ex: except Exception as ex:
if getattr (ex, 'args', [None])[0] not in (2006, 2013):
raise
last = ex 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: if last:
raise last raise last




Loading…
Cancel
Save