From af4138ff515359e1e41d1122c0194ce8d384bb36 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Mon, 13 Jul 2020 13:12:01 -0400 Subject: [PATCH] minor progress refinement --- lbry/blockchain/sync/claims.py | 12 ++++++------ lbry/blockchain/sync/supports.py | 4 ++-- lbry/console.py | 5 ++++- lbry/db/query_context.py | 2 ++ 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lbry/blockchain/sync/claims.py b/lbry/blockchain/sync/claims.py index de09b0526..dd4db8ce0 100644 --- a/lbry/blockchain/sync/claims.py +++ b/lbry/blockchain/sync/claims.py @@ -58,9 +58,9 @@ def staked_support_count_calc(other): def make_label(action, blocks): if blocks[0] == blocks[-1]: - return f"{action} {blocks[0]}" + return f"{action}{blocks[0]:>6}" else: - return f"{action} {blocks[0]}-{blocks[-1]}" + return f"{action}{blocks[0]:>6}-{blocks[-1]:>6}" def select_claims_for_saving( @@ -113,7 +113,7 @@ def claims_insert( count_unspent_txos( CLAIM_TYPE_CODES, blocks, missing_in_claims_table=missing_in_claims_table, - ), progress_id=blocks[0], label=make_label("add claims at", blocks) + ), progress_id=blocks[0], label=make_label("add claims", blocks) ) with p.ctx.engine.connect().execution_options(stream_results=True) as c: @@ -165,7 +165,7 @@ def claims_constraints_and_indexes(p: ProgressContext): def claims_update(blocks: Tuple[int, int], p: ProgressContext): p.start( count_unspent_txos(CLAIM_TYPE_CODES, blocks, missing_or_stale_in_claims_table=True), - progress_id=blocks[0], label=make_label("update claims at", blocks) + progress_id=blocks[0], label=make_label("mod claims", blocks) ) with p.ctx.engine.connect().execution_options(stream_results=True) as c: loader = p.ctx.get_bulk_loader() @@ -182,14 +182,14 @@ def claims_update(blocks: Tuple[int, int], p: ProgressContext): @event_emitter("blockchain.sync.claims.delete", "claims") def claims_delete(claims, p: ProgressContext): - p.start(claims, label="delete claims") + p.start(claims, label="del claims") deleted = p.ctx.execute(Claim.delete().where(where_abandoned_claims())) p.step(deleted.rowcount) @event_emitter("blockchain.sync.claims.takeovers", "claims") def update_takeovers(blocks: Tuple[int, int], takeovers, p: ProgressContext): - p.start(takeovers, label="winning") + p.start(takeovers, label=make_label("mod winner", blocks)) chain = get_or_initialize_lbrycrd(p.ctx) for takeover in chain.db.sync_get_takeovers(start_height=blocks[0], end_height=blocks[-1]): update_claims = ( diff --git a/lbry/blockchain/sync/supports.py b/lbry/blockchain/sync/supports.py index 1c580b710..f2a951214 100644 --- a/lbry/blockchain/sync/supports.py +++ b/lbry/blockchain/sync/supports.py @@ -26,7 +26,7 @@ def supports_insert(blocks: Tuple[int, int], missing_in_supports_table: bool, p: count_unspent_txos( TXO_TYPES['support'], blocks, missing_in_supports_table=missing_in_supports_table, - ), progress_id=blocks[0], label=make_label("add supports at", blocks) + ), progress_id=blocks[0], label=make_label("add supprt", blocks) ) channel_txo = TXO.alias('channel_txo') select_supports = select( @@ -78,6 +78,6 @@ def supports_constraints_and_indexes(p: ProgressContext): @event_emitter("blockchain.sync.supports.delete", "supports") def supports_delete(supports, p: ProgressContext): - p.start(supports, label="delete supports") + p.start(supports, label="del supprt") deleted = p.ctx.execute(Support.delete().where(where_abandoned_supports())) p.step(deleted.rowcount) diff --git a/lbry/console.py b/lbry/console.py index f2ea6678b..ed122ddc8 100644 --- a/lbry/console.py +++ b/lbry/console.py @@ -392,7 +392,10 @@ class Advanced(Basic): if bar is None: assert d['done'][0] == 0 label = d.get('label', name[-11:]) - self.get_or_create_bar(f"{name}#{d['id']}", label, d['units'], d['total']) + self.get_or_create_bar( + f"{name}#{d['id']}", label, d['units'], d['total'], + name.split('.')[-1] not in ('insert', 'update') + ) else: if d['done'][0] != -1: main_bar_name = f"{name[:name.rindex('.')]}.main" diff --git a/lbry/db/query_context.py b/lbry/db/query_context.py index e2728d361..bc1bf7122 100644 --- a/lbry/db/query_context.py +++ b/lbry/db/query_context.py @@ -244,6 +244,8 @@ def event_emitter(name: str, *units: str, throttle=1): with progress(event, throttle=throttle) as p: try: return f(*args, **kwargs, p=p) + except BreakProgress: + raise except: traceback.print_exc() raise