Skip to content

Commit

Permalink
添加redis/pg创建连接时的超时参数 (#1311) (#1321)
Browse files Browse the repository at this point in the history
  • Loading branch information
weideguo authored Jan 11, 2022
1 parent 4131417 commit 556ff57
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sql/engines/pgsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_connection(self, db_name=None):
if self.conn:
return self.conn
self.conn = psycopg2.connect(host=self.host, port=self.port, user=self.user,
password=self.password, dbname=db_name)
password=self.password, dbname=db_name, connect_timeout=10)
return self.conn

@property
Expand Down
2 changes: 1 addition & 1 deletion sql/engines/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RedisEngine(EngineBase):
def get_connection(self, db_name=None):
db_name = db_name or self.db_name
return redis.Redis(host=self.host, port=self.port, db=db_name, password=self.password,
encoding_errors='ignore', decode_responses=True)
encoding_errors='ignore', decode_responses=True, socket_connect_timeout=10)

@property
def name(self):
Expand Down

0 comments on commit 556ff57

Please sign in to comment.