m
Size: a a a
m
В
class VideoCreatorWorker(Thread):И вот такой поставщик
def __init__(self, db_connect, *args, **kwargs):
super(VideoCreatorWorker, self).__init__(*args, **kwargs)
self.__credentials = pika.PlainCredentials('user', 'user')
self.__host = 'localhost'
self.__port = 5672
self.__virtual_host = '/'
self.__name_queue = 'task_queue'
def callback(self, channel, method, properties, body):
print("{} received '{}'".format(self.name, body))
def run(self):
connection = pika.BlockingConnection(
pika.ConnectionParameters(
host=self.__host,
port=self.__port,
virtual_host=self.__virtual_host,
credentials=self.__credentials
)
)
channel = connection.channel()
channel.basic_consume(self.__name_queue,
on_message_callback=self.callback,
)
channel.start_consuming()
async def render(self,Как мне в поставщике узнать что отправленная им, конкретная задача, выполнилась ?
components_id:int,
background_tasks: BackgroundTasks,
videos_components:VideosComponentRepository,
video_repository: VideoRepository):
videos_components_obj = await videos_components.get_by_id(components_id)
new_video = VideoIn(
name=videos_components_obj.name,
video_components_id=videos_components_obj.id,
owner_id=videos_components_obj.owner_id,
)
new_video = await video_repository.create(new_video)
body = {
'video_components':jsonable_encoder(videos_components_obj),
'video_id':new_video.id
}
credentials = pika.PlainCredentials('user', 'user')
connection = pika.BlockingConnection(
pika.ConnectionParameters(
host='localhost',
port=5672,
virtual_host='/',
credentials=credentials
)
)
channel = connection.channel()
channel.queue_declare(queue='task_queue', durable=True)
channel.basic_publish(
exchange='',
routing_key='task_queue',
body = json.dumps(body),
properties=pika.BasicProperties(
delivery_mode=2, # make message persistent
),
)
connection.close()
A
class VideoCreatorWorker(Thread):И вот такой поставщик
def __init__(self, db_connect, *args, **kwargs):
super(VideoCreatorWorker, self).__init__(*args, **kwargs)
self.__credentials = pika.PlainCredentials('user', 'user')
self.__host = 'localhost'
self.__port = 5672
self.__virtual_host = '/'
self.__name_queue = 'task_queue'
def callback(self, channel, method, properties, body):
print("{} received '{}'".format(self.name, body))
def run(self):
connection = pika.BlockingConnection(
pika.ConnectionParameters(
host=self.__host,
port=self.__port,
virtual_host=self.__virtual_host,
credentials=self.__credentials
)
)
channel = connection.channel()
channel.basic_consume(self.__name_queue,
on_message_callback=self.callback,
)
channel.start_consuming()
async def render(self,Как мне в поставщике узнать что отправленная им, конкретная задача, выполнилась ?
components_id:int,
background_tasks: BackgroundTasks,
videos_components:VideosComponentRepository,
video_repository: VideoRepository):
videos_components_obj = await videos_components.get_by_id(components_id)
new_video = VideoIn(
name=videos_components_obj.name,
video_components_id=videos_components_obj.id,
owner_id=videos_components_obj.owner_id,
)
new_video = await video_repository.create(new_video)
body = {
'video_components':jsonable_encoder(videos_components_obj),
'video_id':new_video.id
}
credentials = pika.PlainCredentials('user', 'user')
connection = pika.BlockingConnection(
pika.ConnectionParameters(
host='localhost',
port=5672,
virtual_host='/',
credentials=credentials
)
)
channel = connection.channel()
channel.queue_declare(queue='task_queue', durable=True)
channel.basic_publish(
exchange='',
routing_key='task_queue',
body = json.dumps(body),
properties=pika.BasicProperties(
delivery_mode=2, # make message persistent
),
)
connection.close()
A
GG
D
ИГ
SM
ВУ
SV
D
IC
A
m
A
m
/
на винде диск. например 'C:\'A
МH
V
SM