-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
33 lines (21 loc) · 731 Bytes
/
main.py
File metadata and controls
33 lines (21 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import json
import os
import pika
import render_ffmpeg
def print_log(*args):
print(' '.join([str(arg) for arg in args]), end="\n")
def main():
connection = pika.BlockingConnection(pika.ConnectionParameters(host=os.environ['RABBITMQ_HOST']))
channel = connection.channel()
channel.queue_declare(queue='render')
def callback(ch, method, properties, body):
try:
data = json.loads(body)
print_log(data)
render_ffmpeg.render(data)
except Exception as ex:
print_log('Error caused:', ex)
channel.basic_consume(queue='render', on_message_callback=callback, auto_ack=True)
channel.start_consuming()
if __name__ == '__main__':
main()