diff --git a/src/maggma/stores/gridfs.py b/src/maggma/stores/gridfs.py index 0f4fafe2c..1d56ec9d8 100644 --- a/src/maggma/stores/gridfs.py +++ b/src/maggma/stores/gridfs.py @@ -132,14 +132,14 @@ def connect(self, force_reset: bool = False): force_reset: whether to reset the connection or not when the Store is already connected. """ - if self.ssh_tunnel is None: - host = self.host - port = self.port - else: - self.ssh_tunnel.start() - host, port = self.ssh_tunnel.local_address - if not self._coll or force_reset: + if self.ssh_tunnel is None: + host = self.host + port = self.port + else: + self.ssh_tunnel.start() + host, port = self.ssh_tunnel.local_address + conn: MongoClient = ( MongoClient( host=host, diff --git a/src/maggma/stores/mongolike.py b/src/maggma/stores/mongolike.py index 45206b956..28ecaf096 100644 --- a/src/maggma/stores/mongolike.py +++ b/src/maggma/stores/mongolike.py @@ -179,14 +179,14 @@ def connect(self, force_reset: bool = False): force_reset: whether to reset the connection or not when the Store is already connected. """ - if self.ssh_tunnel is None: - host = self.host - port = self.port - else: - self.ssh_tunnel.start() - host, port = self.ssh_tunnel.local_address - if self._coll is None or force_reset: + if self.ssh_tunnel is None: + host = self.host + port = self.port + else: + self.ssh_tunnel.start() + host, port = self.ssh_tunnel.local_address + conn: MongoClient = ( MongoClient( host=host,