Skip to content

Commit

Permalink
fix: close mongo clients when dropping dbs
Browse files Browse the repository at this point in the history
  • Loading branch information
jvansanten committed Nov 28, 2024
1 parent 27f24a1 commit 1d33fae
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ampel/core/AmpelDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,13 @@ def __repr__(self) -> str:
return "<AmpelDB>"


def drop_all_databases(self):
def drop_all_databases(self) -> None:
for db in self.databases:
pym_db = self._get_pymongo_db(db.name, role=db.role.w)
pym_db.client.drop_database(pym_db.name)
self.mongo_collections.clear()
for mc in self.mongo_clients.values():
mc.close()
self.mongo_clients.clear()
# deleting the attribute resets cached_property
for attr in ("col_trace_ids", "col_conf_ids", "trace_ids", "conf_ids"):
Expand Down

0 comments on commit 1d33fae

Please sign in to comment.