From 6cd1e4fc692c8e7f95bf2bfba4303002a45a53c7 Mon Sep 17 00:00:00 2001 From: wuaho Date: Tue, 14 Sep 2021 12:19:34 +0800 Subject: [PATCH] update --- config.py | 16 +++++++++++++++- update_data/update_data.py | 7 +++++-- update_data/update_user.py | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/config.py b/config.py index 126bf26..e2ac595 100644 --- a/config.py +++ b/config.py @@ -1,4 +1,5 @@ import os +import sys from loguru import logger @@ -458,4 +459,17 @@ class ProductionConfig(Config): } -settings = ProductionConfig() +class DebugConfig(Config): + GAME_MANA_MYSQLDB = { + "host": "127.0.0.1", + "port": 3306, + "user": "root", + "password": "root", + "db": "gamemana" + } + + +if sys.platform == 'linux': + settings = ProductionConfig() +else: + settings = DebugConfig() diff --git a/update_data/update_data.py b/update_data/update_data.py index b134659..3cedc08 100644 --- a/update_data/update_data.py +++ b/update_data/update_data.py @@ -39,8 +39,11 @@ class LoadData(metaclass=abc.ABCMeta): sql = 'replace into gm_kv set k=%s,v=%s' async with self.gm_db_pool.acquire() as conn: async with conn.cursor() as cur: - await cur.execute(sql, (key, value)) - await conn.commit() + try: + await cur.execute(sql, (key, value)) + await conn.commit() + except Exception as e: + logger.error(e) @abc.abstractmethod async def get_data(self): diff --git a/update_data/update_user.py b/update_data/update_user.py index c249b86..c2c17a4 100644 --- a/update_data/update_user.py +++ b/update_data/update_user.py @@ -28,7 +28,7 @@ class LoadUserData(LoadData): self.last_act_time = await self.get_kv(self.gm_key) where = { - 'logintime': {'$gte': self.last_act_time, '$lt': self.act_time} + 'logintime': {'$gte': self.last_act_time-600, '$lt': self.act_time} } projection = { '_id': False,