[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [sbws/master] Catch json decode error when loading results



commit 991fe852683257f23d243c5f79809886adb1f7ea
Author: juga0 <juga@xxxxxxxxxx>
Date:   Mon Jun 25 10:10:09 2018 +0000

    Catch json decode error when loading results
    
    log the error, ingore the line and continue
---
 sbws/lib/resultdump.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/sbws/lib/resultdump.py b/sbws/lib/resultdump.py
index 9f4f57a..755eb2d 100644
--- a/sbws/lib/resultdump.py
+++ b/sbws/lib/resultdump.py
@@ -44,7 +44,11 @@ def load_result_file(fname, success_only=False):
         with open(fname, 'rt') as fd:
             for line in fd:
                 num_total += 1
-                r = Result.from_dict(json.loads(line.strip()))
+                try:
+                    r = Result.from_dict(json.loads(line.strip()))
+                except json.decoder.JSONDecodeError:
+                    log.warning('Could not decode result %s', line.strip())
+                    r = None
                 if r is None:
                     num_ignored += 1
                     continue



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits