-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Closed
Labels
🙋♀️ questionFurther information is requestedFurther information is requested
Description
Describe your problem
Why aren't thread pools used here
@singleton
class RedisDB:
def init(self):
self.REDIS = None
self.config = settings.REDIS
self.open()
# def __open__(self):
# try:
# self.REDIS = redis.StrictRedis(
# host=self.config["host"],
# port=int(self.config["port"]),
# db=int(self.config["database"]),
# password=self.config.get("password"),
# decode_responses=True,
# )
# except Exception:
# logging.warning("Redis can't be connected.")
# return self.REDIS
def __open__(self):
try:
self.pool = redis.ConnectionPool(
host=self.config["host"],
port=int(self.config["port"]),
db=int(self.config["database"]),
password=self.config.get("password"),
decode_responses=True,
max_connections=100 # 设置最大连接数
)
self.REDIS = redis.StrictRedis(
connection_pool=self.pool
)
except Exception:
logging.warning("Redis can't be connected.")
return self.REDIS
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
🙋♀️ questionFurther information is requestedFurther information is requested