Hopefully fix the Too many open files issue

This commit is contained in:
TheTechRobo 2022-04-01 21:22:18 -04:00
parent 5c11653d32
commit 708013fed0
1 changed files with 8 additions and 2 deletions

View File

@ -15,9 +15,15 @@ class PlaceScraper:
while True:
try:
conn = await r.connect()
return await r.db(db).table(table).insert(data).run(conn)
d = await r.db(db).table(table).insert(data).run(conn)
conn.close()
return d
except rethinkdb.errors.ReqlDriverError as ename:
print(f"Retrying DB transaction... ({ename})")
try:
conn.close()
except NameError:
pass
await asyncio.sleep(2)
async def download_and_add_to_db(self, url, sesh):
while True:
@ -63,4 +69,4 @@ while True:
STOP = True
if STOP:
print("\tSTOP: Exited gracefully after CtrlC.")
break
sys.exit(130)