忽略定时任务执行过程中发生的错误

This commit is contained in:
zayac 2024-02-29 20:30:42 +08:00
parent 2167eab50f
commit ad316cf596

View File

@ -1,5 +1,4 @@
import time
import schedule
from loguru import logger
@ -13,24 +12,33 @@ from src.entity.visual_list import text_count_by_user
def job_count(username, password):
logger.info(f'Running job_count for username: {username}')
user = get_user_by_username_and_password(username, password)
send_message(BOT_TOKEN, COUNT_GROUP_ID, text_count_by_user(user, get_curr_day()))
logger.info(f'Finished job_count for username: {username}')
try:
logger.info(f'Running job_count for username: {username}')
user = get_user_by_username_and_password(username, password)
send_message(BOT_TOKEN, COUNT_GROUP_ID, text_count_by_user(user, get_curr_day()))
logger.info(f'Finished job_count for username: {username}')
except Exception as e:
logger.error(f'Error running job_count for username: {username}, Error: {e}')
def query_failed_deposit(username, password):
logger.info(f'Running query_failed_deposit for username: {username}')
user = get_user_by_username_and_password(username, password)
send_message(BOT_TOKEN, COUNT_GROUP_ID, get_pay_failed_by_user(user, get_curr_day()))
logger.info(f'Finished query_failed_deposit for username: {username}')
try:
logger.info(f'Running query_failed_deposit for username: {username}')
user = get_user_by_username_and_password(username, password)
send_message(BOT_TOKEN, COUNT_GROUP_ID, get_pay_failed_by_user(user, get_curr_day()))
logger.info(f'Finished query_failed_deposit for username: {username}')
except Exception as e:
logger.error(f'Error running query_failed_deposit for username: {username}, Error: {e}')
def query_net_win(username, password) -> None:
logger.info(f'Running query_net_win for username: {username}')
user = get_user_by_username_and_password(username, password)
send_message(BOT_TOKEN, COUNT_GROUP_ID, get_net_win_by_user(user, date=get_curr_day()))
logger.info(f'Finished query_net_win for username: {username}')
def query_net_win(username, password):
try:
logger.info(f'Running query_net_win for username: {username}')
user = get_user_by_username_and_password(username, password)
send_message(BOT_TOKEN, COUNT_GROUP_ID, get_net_win_by_user(user, date=get_curr_day()))
logger.info(f'Finished query_net_win for username: {username}')
except Exception as e:
logger.error(f'Error running query_net_win for username: {username}, Error: {e}')
if __name__ == '__main__':
@ -43,4 +51,4 @@ if __name__ == '__main__':
while True:
schedule.run_pending()
time.sleep(1)
# logger.info('Running scheduled tasks')
# logger.info('Running scheduled tasks') # This line is commented out to reduce log verbosity