Commit 29539169 by yexing

更新代理IP

parent 8ca54d41
......@@ -13,6 +13,7 @@ if not IS_DEBUG:
logger.remove()
logger.add(LOG_PATH, level="INFO", rotation="1 day", retention="1 months")
class Subsidiary:
def __init__(self):
self._tasks = []
......@@ -21,7 +22,12 @@ class Subsidiary:
async def connect(self):
if self.r is None:
self.r = redis.Redis(host="localhost", port=6380, db=0)
self.r = redis.Redis(
host="localhost",
port=int(os.getenv("REDIS_HOST", 6380)),
password=os.getenv("REDIS_PASSWORD"),
db=0,
)
if await self.r.ping():
logger.info("redis 连接成功")
......@@ -56,8 +62,7 @@ class Subsidiary:
logger.info("资源已回收")
async def run_during_night(self):
"""在晚上运行任务
"""
"""在晚上运行任务"""
while True:
now = datetime.now().time()
if time(22, 0) > now and now > time(7, 0):
......@@ -86,6 +91,7 @@ class Subsidiary:
finally:
await self.close()
if __name__ == "__main__":
loop = asyncio.get_event_loop()
if IS_DEBUG:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment