Skip to content

Commit

Permalink
Minor modification in ssh connection
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasFehring committed Apr 17, 2024
1 parent 0d8997c commit 1eeeffd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions py_experimenter/database_connector_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,16 @@ def start_ssh_tunnel(self, logger: Logger):
tunnel = self.get_ssh_tunnel(logger)
# Tunnels may not be stopepd instantly, so we check if the tunnel is active before starting it
if tunnel is not None and not tunnel.is_active:
tunnel.start()
try:
tunnel.start()
except Exception as e:
logger.warning("Failed at creating SSH tunnel. Maybe the tunnel is already active in other process?")
logger.warning(e)

def close_ssh_tunnel(self):
tunnel = self.get_ssh_tunnel(self.logger)
if tunnel is not None:
tunnel.stop(force=True)
tunnel.stop(force=False)

def _test_connection(self):
try:
Expand Down

0 comments on commit 1eeeffd

Please sign in to comment.