This is the fourth part of Celery and RabbitMQ in Django series. Today I will fix minor bugs and sum up this series.
Audio File detail view
This is the first bug that I wanted to tackle. Did you remember my last post ? At the end there was a bug show below:
Right now everything works great but what if something goes wrong? To make sure that I will be able to find the issue I need logging. This is especially valuable for celery because Django doesn't show output from Celery as it is a different application. So to setup basic logging I need to add only a few things in tasks.py:
from celery.utils.log import get_task_logger logger = get_task_logger(__name__) @app.task def transcode_mp3(mp3_id): # ... logger.debug( 'Created output files: %s, %s, %s.', ogg_output_file_path, ac3_output_file_path, wav_output_file_path ) logger.info('Started transcoding.') # transcoding here logger.info('End of transcoding.') # rest of program ...
Thanks to that I can see in my console:
[2016-03-19 09:55:07,184: INFO/Worker-4] taskapp.tasks.transcode_mp3[b6ca93d4-e58c-496f-b8e5-4ba493b8a92a]: Started transcoding. # transcoding ... [2016-03-19 09:55:11,837: INFO/Worker-4] taskapp.tasks.transcode_mp3[b6ca93d4-e58c-496f-b8e5-4ba493b8a92a]: End of transcoding.
This was the last post of Django Celery Rabbit series. I made basic transcoder application that uses FFmpeg, Django, Celery and RabbitMQ. I learned quite a bit about how celery works with rabbitmq and django. Thanks to that I stumbled upon some useful blog posts. I also see some issues with my solutions. For instance todays AudioFile detail view. I'm thinking about other ways to solve this problem because right now I need 2 operations on database for one file. Maybe you know solution to this? I'm really keen to hear about your view on this issue or other comments so feel free to write comments or send me an email! Thanks to all people who give me feedback- I really appreciate this! Code for this series can be found on github.