Advertisement
Guest User

celery_migration

a guest
Feb 28th, 2020
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. @signals.task_success.connect(sender='this.task.location')
  2.   def migrations_success_notifcation(
  3.     result,
  4.     *args,
  5.     **kwargs
  6.   ):
  7.     print(result)
  8.  
  9.   @signals.task_failure.connect(sender='this.task.location')
  10.   def migrations_failure_notification(
  11.     task_id,
  12.     exception,
  13.     traceback,
  14.     *args,
  15.     **kwargs
  16.   ):
  17.     logging.info(
  18.         task_id,
  19.         exception,
  20.         args,
  21.         kwargs,
  22.         traceback
  23.     )
  24.  
  25.   @app.task
  26.   def run_migrations(**kwargs):
  27.     # The following print will log just fine
  28.     print('HELOOOOOO TASK')
  29.  
  30.     execute_from_command_line([
  31.         "../../manage.py",
  32.         "migrate"
  33.     ])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement