From 564018c937a0663850fa46c1f67458b88c95ba16 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Sat, 27 Jun 2020 11:46:49 -0400 Subject: [PATCH] better debug badrow --- lbry/db/query_context.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lbry/db/query_context.py b/lbry/db/query_context.py index b7aba73c0..bf8c5dc6f 100644 --- a/lbry/db/query_context.py +++ b/lbry/db/query_context.py @@ -570,19 +570,21 @@ class BulkLoader: for chunk_rows in chunk(rows, batch_size): try: execute(sql, chunk_rows) - except: + except Exception: for row in chunk_rows: try: execute(sql, [row]) - except: - print(sql) - print(row) - with open('badrow', 'wb') as badrow: - badrow.write(str(sql).encode()) - badrow.write(repr(row).encode()) + except Exception: p.ctx.message_queue.put_nowait( (Event.COMPLETE.value, os.getpid(), 1, 1) ) + with open('badrow', 'a') as badrow: + badrow.write(repr(sql)) + badrow.write('\n') + badrow.write(repr(row)) + badrow.write('\n') + print(sql) + print(row) raise if p: done += int(len(chunk_rows)/row_scale)