Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复mongodb ssh tunnel 超时问题 #2652

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

xiaoshumiao6
Copy link
Contributor

修复问题:
#2546

Copy link
Collaborator

@LeoQuote LeoQuote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

有过多重复的 conn.close , 如果想避免过多的重复连接, 请参考 mysqlengine 的做法

def close(self):
if self.conn:
self.conn.close()
self.conn = None
定义一个 close 函数

然后做一个公用的 query 方法, 内部逻辑为, 获取连接, 做查询, 支持一个 close 参数, 如果 close 为 True, 则在查询后将连接关闭, 其他方法复用该方法, 这样可以使得代码更加简洁

隧道关闭应该不需额外声明, Engine base 内定义了

def __del__(self):
if hasattr(self, "ssh"):
del self.ssh
if hasattr(self, "remotessh"):
del self.remotessh

应该会在view 退出时端口连接, 不会造成连接泄露

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants