@@ -49,7 +49,7 @@ def __getConnection(self):
49
49
def __removeConnection (self ):
50
50
self .__connection = None
51
51
52
- @retry (stop = stop_after_attempt (3 ), wait = wait_fixed (10 ), retry = retry_if_exception_type (pyodbc .Error ), after = after_log (app .logger , logging .DEBUG ))
52
+ @retry (stop = stop_after_attempt (3 ), wait = wait_fixed (10 ), retry = retry_if_exception_type (pyodbc .OperationalError ), after = after_log (app .logger , logging .DEBUG ))
53
53
def executeQueryJSON (self , procedure , payload = None ):
54
54
result = {}
55
55
try :
@@ -70,15 +70,14 @@ def executeQueryJSON(self, procedure, payload=None):
70
70
result = {}
71
71
72
72
cursor .commit ()
73
- except pyodbc .Error as e :
74
- if isinstance (e , pyodbc .ProgrammingError ) or isinstance (e , pyodbc .OperationalError ):
75
- app .logger .error (f"{ e .args [1 ]} " )
76
- if e .args [0 ] == "08S01" :
77
- # If there is a "Communication Link Failure" error,
78
- # then connection must be removed
79
- # as it will be in an invalid state
80
- self .__removeConnection ()
81
- raise
73
+ except pyodbc .OperationalError as e :
74
+ app .logger .error (f"{ e .args [1 ]} " )
75
+ if e .args [0 ] == "08S01" :
76
+ # If there is a "Communication Link Failure" error,
77
+ # then connection must be removed
78
+ # as it will be in an invalid state
79
+ self .__removeConnection ()
80
+ raise
82
81
finally :
83
82
cursor .close ()
84
83
0 commit comments