From 928cb418e74ee32863e449bc937fd60e8a8eb9f1 Mon Sep 17 00:00:00 2001 From: BennyThink Date: Wed, 3 Feb 2021 20:42:50 +0800 Subject: [PATCH] num_threads change it to 100 to make it work - temp solution --- README.md | 4 ++++ requirements.txt | 2 +- yyetsbot/bot.py | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6db811b..2404dee 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,10 @@ python /path/to/YYeTsBot/yyetsbot/bot.py ## health check 有时不知为何遇到了bot卡死,无任何反馈。😂这个时候需要client api了😂 +好的,这个原因找到了,是因为有时爬虫会花费比较长的时间,然后pytelegrambotapi默认只有两个线程,那么后续的操作就会被阻塞住。 + +临时的解决办法是增加线程数量,长期的解决办法是使用celery分发任务。 + # Credits * [人人影视](http://www.zmz2019.com/) diff --git a/requirements.txt b/requirements.txt index fbb2a6b..7c05b0f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ requests -pytelegrambotapi +pytelegrambotapi==3.7.6 beautifulsoup4 tgbot-ping redis diff --git a/yyetsbot/bot.py b/yyetsbot/bot.py index 720ffc1..bc2509e 100644 --- a/yyetsbot/bot.py +++ b/yyetsbot/bot.py @@ -29,7 +29,7 @@ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(filename)s [%(le if PROXY: apihelper.proxy = {'http': PROXY} -bot = telebot.TeleBot(TOKEN) +bot = telebot.TeleBot(TOKEN, num_threads=100) angry_count = 0 @@ -365,4 +365,4 @@ if __name__ == '__main__': scheduler = BackgroundScheduler() scheduler.add_job(reset_request, 'cron', hour=0, minute=0) scheduler.start() - bot.polling() \ No newline at end of file + bot.polling()