close db in sync script

This commit is contained in:
Jack Robison 2021-06-17 21:30:31 -04:00 committed by Victor Shyba
parent 4ce16b6509
commit 92be63ff5b

View file

@ -21,8 +21,16 @@ async def get_all_claims(index_name='claims', db=None):
db = db or LevelDB(env) db = db or LevelDB(env)
if need_open: if need_open:
await db.open_dbs() await db.open_dbs()
for claim in db.all_claims_producer(): try:
yield extract_doc(claim, index_name) cnt = 0
for claim in db.all_claims_producer():
yield extract_doc(claim, index_name)
cnt += 1
if cnt % 10000 == 0:
print(f"{cnt} claims sent")
finally:
if need_open:
db.close()
async def make_es_index(index=None): async def make_es_index(index=None):