Сервер на Apache. За вебхуки отвечает Flask
from flask import Flask, request, redirect
from telebot import types
import requests, json, time
from main import *
from config import *
app = Flask(__name__)
@app.route('/' + BOT_HASH, methods=['POST'])
def webhooks():
json_string = request.get_data().decode('utf-8')
update = types.Update.de_json(json_string)
bot.process_new_updates([update])
return ''
if __name__ == '__main__':
app.run()
bot находится в main
BOT_HASH в config
Ошибка в логе апаче:
[Fri Jun 05 07:14:03.699910 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] [2020-06-05 07:14:03,699] ERROR in app: Exception on /1277178986:AAGzs_KXhPMZmQ2k7k5TKorAMBnfjrrbAMo [POST]
[Fri Jun 05 07:14:03.699936 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] Traceback (most recent call last):
[Fri Jun 05 07:14:03.699941 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] File "/home/ubuntu/.local/lib/python3.6/site-packages/flask/app.py", line 2447, in wsgi_app
[Fri Jun 05 07:14:03.699945 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] response = self.full_dispatch_request()
[Fri Jun 05 07:14:03.699949 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] File "/home/ubuntu/.local/lib/python3.6/site-packages/flask/app.py", line 1952, in full_dispatch_request
[Fri Jun 05 07:14:03.699953 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] rv = self.handle_user_exception(e)
[Fri Jun 05 07:14:03.699957 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] File "/home/ubuntu/.local/lib/python3.6/site-packages/flask/app.py", line 1821, in handle_user_exception
[Fri Jun 05 07:14:03.699961 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] reraise(exc_type, exc_value, tb)
[Fri Jun 05 07:14:03.699965 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] File "/home/ubuntu/.local/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
[Fri Jun 05 07:14:03.699969 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] raise value
[Fri Jun 05 07:14:03.699973 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] File "/home/ubuntu/.local/lib/python3.6/site-packages/flask/app.py", line 1950, in full_dispatch_request
[Fri Jun 05 07:14:03.699977 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] rv = self.dispatch_request()
[Fri Jun 05 07:14:03.699981 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] File "/home/ubuntu/.local/lib/python3.6/site-packages/flask/app.py", line 1936, in dispatch_request
[Fri Jun 05 07:14:03.699985 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] return self.view_functions[rule.endpoint](**req.view_args)
[Fri Jun 05 07:14:03.699989 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] File "/home/ubuntu/servicebot/app.py", line 36, in webhooks
[Fri Jun 05 07:14:03.699993 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] bot.process_new_updates([update])
[Fri Jun 05 07:14:03.699998 2020] [wsgi:error] [pid 993:tid 140389314250496] [remote 91.108.6.159:42330] AttributeError: 'Bot' object has no attribute 'process_new_updates'
Ошибка появляется не всегда, а только если долго не писать ничего боту. Возможно проблема в том, что экземпляр бота импортируется из другого скрипта и "устаревает" со временем, но в любом случае подскажите, не хочу словить эту ошибку еще раз