Hopefully fix the Too many open files issue
This commit is contained in:
parent
5c11653d32
commit
708013fed0
10
script.py
10
script.py
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue