close dbclient after usage
This commit is contained in:
parent
bcc64c767c
commit
3276619e6f
|
@ -90,6 +90,7 @@ def _handle_kres_file_tpl(kres_file_tpl):
|
||||||
kres_col.insert_many(kres_data_1) # much much better (just make sure sid has a unique index)
|
kres_col.insert_many(kres_data_1) # much much better (just make sure sid has a unique index)
|
||||||
logger.info("Inserted data from {} ({}/{}) in {:.2f} s".format(
|
logger.info("Inserted data from {} ({}/{}) in {:.2f} s".format(
|
||||||
kres_file, kres_file_idx, n_kres_files, time.time() - tstart))
|
kres_file, kres_file_idx, n_kres_files, time.time() - tstart))
|
||||||
|
dbclient.close()
|
||||||
|
|
||||||
def _get_dbclient(args):
|
def _get_dbclient(args):
|
||||||
dbclient = MongoClient(
|
dbclient = MongoClient(
|
||||||
|
@ -130,6 +131,7 @@ if __name__ == "__main__":
|
||||||
dbclient.valdb[corpus].ensure_index([("sid", pymongo.ASCENDING)])
|
dbclient.valdb[corpus].ensure_index([("sid", pymongo.ASCENDING)])
|
||||||
dbclient.valdb[corpus].ensure_index([("headwords", pymongo.ASCENDING)])
|
dbclient.valdb[corpus].ensure_index([("headwords", pymongo.ASCENDING)])
|
||||||
dbclient.valdb[corpus].ensure_index([("functors", pymongo.ASCENDING)])
|
dbclient.valdb[corpus].ensure_index([("functors", pymongo.ASCENDING)])
|
||||||
|
dbclient.close()
|
||||||
|
|
||||||
|
|
||||||
if corpus == "ssj":
|
if corpus == "ssj":
|
||||||
|
@ -147,6 +149,7 @@ if __name__ == "__main__":
|
||||||
for sentence in ssj_data:
|
for sentence in ssj_data:
|
||||||
sentence = _db_preprocess(sentence)
|
sentence = _db_preprocess(sentence)
|
||||||
ssj_col.update({"sid": sentence["sid"]}, sentence, upsert=True)
|
ssj_col.update({"sid": sentence["sid"]}, sentence, upsert=True)
|
||||||
|
dbclient.close()
|
||||||
|
|
||||||
|
|
||||||
if corpus == "kres":
|
if corpus == "kres":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user