This commit is contained in:
Administrator
2024-12-22 22:20:02 +03:00
parent 5a00dad803
commit 4d03af75d8
4 changed files with 26 additions and 42 deletions

View File

@@ -1,18 +1,3 @@
import os
import grpc
from queues import tasks_pb2_grpc
stage = os.getenv("STAGE", 'local')
if stage == 'local':
QUEUES_URL = 'localhost:50051'
else:
QUEUES_URL = 'queues-grpc:50051'
class Daemon:
def __init__(self):
self.channel = grpc.insecure_channel(QUEUES_URL)
self.stub = tasks_pb2_grpc.TasksStub(channel=self.channel)
def execute(self):
raise NotImplemented

View File

@@ -9,7 +9,6 @@ from utils import queues
class Daemon(base.Daemon):
def __init__(self):
super().__init__()
self.processes: dict[str, multiprocessing.Process|None] = {}
def execute(self):
@@ -42,5 +41,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(self.stub, queue, message.json, 1)
queues.set_task(queue, message.json, 1)
bot.polling()