From 4d321ae069fce2c0f6f7884bec8fa6c4ec534d1a Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期四, 03 八月 2023 18:25:33 +0800
Subject: [PATCH] redis连接池归还

---
 inited_data.py |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/inited_data.py b/inited_data.py
index f1715e1..db9ecd3 100644
--- a/inited_data.py
+++ b/inited_data.py
@@ -36,17 +36,23 @@
 # 璁剧疆璐︽埛淇℃伅
 def setAccountInfo(accountId, strategyId, token):
     redis = redisManager.getRedis()
-    RedisUtils.set(redis, "juejin-account-id", accountId)
-    RedisUtils.set(redis, "juejin-strategy-id", strategyId)
-    RedisUtils.set(redis, "juejin-token", token)
+    try:
+        RedisUtils.set(redis, "juejin-account-id", accountId, auto_free=False)
+        RedisUtils.set(redis, "juejin-strategy-id", strategyId, auto_free=False)
+        RedisUtils.set(redis, "juejin-token", token, auto_free=False)
+    finally:
+        redis.connection_pool.disconnect()
 
 
 def getAccountInfo():
     redis = redisManager.getRedis()
-    account_id = RedisUtils.get(redis, "juejin-account-id")
-    strategy_id = RedisUtils.get(redis, "juejin-strategy-id")
-    token = RedisUtils.get(redis, "juejin-token")
-    return account_id, strategy_id, token
+    try:
+        account_id = RedisUtils.get(redis, "juejin-account-id", auto_free=False)
+        strategy_id = RedisUtils.get(redis, "juejin-strategy-id", auto_free=False)
+        token = RedisUtils.get(redis, "juejin-token", auto_free=False)
+        return account_id, strategy_id, token
+    finally:
+        redis.connection_pool.disconnect()
 
 
 def init_data():

--
Gitblit v1.8.0