@@ -271,6 +271,7 @@ def run_rate(instrument_id, n_hours=24):
271
271
:param n_hours: number of hours to track
272
272
"""
273
273
# Try calling the stored procedure (faster)
274
+ msg = "" # start with empty message to help with logging
274
275
try :
275
276
cursor = connection .cursor ()
276
277
cursor .callproc ("run_rate" , (instrument_id .id ,))
@@ -282,6 +283,7 @@ def run_rate(instrument_id, n_hours=24):
282
283
except Exception :
283
284
connection .close ()
284
285
logging .exception ("Call to stored procedure run_rate(%s) failed" , str (instrument_id ))
286
+ logging .error ("Running query from python" )
285
287
286
288
# Do it by hand (slow)
287
289
time = timezone .now ()
@@ -295,6 +297,8 @@ def run_rate(instrument_id, n_hours=24):
295
297
runs .append ([- i , n ])
296
298
return runs
297
299
except SystemExit :
300
+ if msg : # skip empty string
301
+ logging .error ("message returned from fetchone: %s" , str (msg ))
298
302
logging .exception ("Call to stored procedure error_rate(%s) created system exit" , str (instrument_id ))
299
303
raise
300
304
@@ -308,6 +312,7 @@ def error_rate(instrument_id, n_hours=24):
308
312
:param n_hours: number of hours to track
309
313
"""
310
314
# Try calling the stored procedure (faster)
315
+ msg = "" # start with empty message to help with logging
311
316
try :
312
317
cursor = connection .cursor ()
313
318
cursor .callproc ("error_rate" , (instrument_id .id ,))
@@ -316,9 +321,10 @@ def error_rate(instrument_id, n_hours=24):
316
321
rows = cursor .fetchall ()
317
322
cursor .close ()
318
323
return [[int (r [0 ]), int (r [1 ])] for r in rows ]
319
- except Exception as e :
324
+ except Exception :
320
325
connection .close ()
321
- logging .exception ("Call to stored procedure error_rate(%s) failed: %s" , str (instrument_id ), str (e ))
326
+ logging .exception ("Call to stored procedure error_rate(%s) failed" , str (instrument_id ))
327
+ logging .error ("Running query from python" )
322
328
323
329
# Do it by hand (slow)
324
330
time = timezone .now ()
@@ -335,7 +341,9 @@ def error_rate(instrument_id, n_hours=24):
335
341
errors .append ([- i , n ])
336
342
return errors
337
343
except SystemExit :
338
- logging .exception ("Call to stored procedure error_rate(%s) created system exit: %s" , str (instrument_id ))
344
+ if msg : # skip empty string
345
+ logging .error ("message returned from fetchone: %s" , str (msg ))
346
+ logging .exception ("Call to stored procedure error_rate(%s) created system exit" , str (instrument_id ))
339
347
raise
340
348
341
349
0 commit comments