Guest User

Untitled

a guest
Aug 17th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. How to purge all tasks of a specific que with celery in python?
  2. CELERY_ROUTES = {"socialreport.tasks.twitter_save": {"queue": "twitter_save"}}
  3.  
  4. from celery.bin.camqadm import camqadm
  5. camqadm('queue.purge', queue_name_as_string)
  6.  
  7. kill_command = "ps auxww | grep 'celeryd -n twitter_save' | awk '{print $2}' | xargs kill -9"
  8. subprocess.call(kill_command, shell=True)
  9.  
  10. camqadm('queue.purge', 'twitter_save')
  11. rerun_command = "/home/samos/Software/virt_env/twittersyncv1/bin/python %s/manage.py celeryd -n twitter_save -l info -Q twitter_save" % settings.PROJECT_ROOT
  12.  
  13. os.popen(rerun_command+' &')
  14. send_task("socialreport.tasks.twitter_save")
Add Comment
Please, Sign In to add comment