diff --git a/daemons/poll.py b/daemons/poll.py index d7169ee..d4fe4a4 100644 --- a/daemons/poll.py +++ b/daemons/poll.py @@ -1,6 +1,7 @@ import telebot import multiprocessing import time +import json from daemons import base from utils import platform @@ -41,5 +42,5 @@ class Daemon(base.Daemon): bot = telebot.TeleBot(token) @bot.message_handler(content_types=['audio', 'photo', 'voice', 'video', 'document', 'animation', 'text', 'location', 'contact', 'sticker', 'video_note']) def do_action(message: telebot.types.Message): - queues.set_task(queue, message.json, 1) + queues.set_task(queue, json.loads(message.json), 1) bot.polling() diff --git a/utils/queues.py b/utils/queues.py index c00a18c..dc0f219 100644 --- a/utils/queues.py +++ b/utils/queues.py @@ -17,7 +17,12 @@ class QueuesException(Exception): class TasksHandlerMixin: def poll(self): while True: - response = requests.get(f'{QUEUES_URL}/api/v1/take', headers={'queue': self.queue_name}).json() + try: + response = requests.get(f'{QUEUES_URL}/api/v1/take', headers={'queue': self.queue_name}).json() + except requests.JSONDecodeError: + print('Unable to decode json') + time.sleep(3) + continue task = response.get('task') if not task: time.sleep(0.2)