Merge pull request 'master' (#47) from master into dev
Reviewed-on: #47
This commit is contained in:
commit
5102564b84
@ -1,6 +1,7 @@
|
|||||||
import telebot
|
import telebot
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import time
|
import time
|
||||||
|
import json
|
||||||
|
|
||||||
from daemons import base
|
from daemons import base
|
||||||
from utils import platform
|
from utils import platform
|
||||||
@ -41,5 +42,5 @@ class Daemon(base.Daemon):
|
|||||||
bot = telebot.TeleBot(token)
|
bot = telebot.TeleBot(token)
|
||||||
@bot.message_handler(content_types=['audio', 'photo', 'voice', 'video', 'document', 'animation', 'text', 'location', 'contact', 'sticker', 'video_note'])
|
@bot.message_handler(content_types=['audio', 'photo', 'voice', 'video', 'document', 'animation', 'text', 'location', 'contact', 'sticker', 'video_note'])
|
||||||
def do_action(message: telebot.types.Message):
|
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()
|
bot.polling()
|
||||||
|
@ -17,7 +17,12 @@ class QueuesException(Exception):
|
|||||||
class TasksHandlerMixin:
|
class TasksHandlerMixin:
|
||||||
def poll(self):
|
def poll(self):
|
||||||
while True:
|
while True:
|
||||||
|
try:
|
||||||
response = requests.get(f'{QUEUES_URL}/api/v1/take', headers={'queue': self.queue_name}).json()
|
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')
|
task = response.get('task')
|
||||||
if not task:
|
if not task:
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
|
Loading…
Reference in New Issue
Block a user