How do I periodically purge a queue in celery rabbitmq?












0















How can I periodically purge celery queues, like per minute after there are any unfinished task left in queue then I need to purge all those task after a minute.



How do I do this?










share|improve this question





























    0















    How can I periodically purge celery queues, like per minute after there are any unfinished task left in queue then I need to purge all those task after a minute.



    How do I do this?










    share|improve this question



























      0












      0








      0








      How can I periodically purge celery queues, like per minute after there are any unfinished task left in queue then I need to purge all those task after a minute.



      How do I do this?










      share|improve this question
















      How can I periodically purge celery queues, like per minute after there are any unfinished task left in queue then I need to purge all those task after a minute.



      How do I do this?







      python rabbitmq celery






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 14 '18 at 7:25









      petezurich

      3,57581734




      3,57581734










      asked Nov 14 '18 at 7:23









      Shersha FnShersha Fn

      52211127




      52211127
























          2 Answers
          2






          active

          oldest

          votes


















          1














          If you need to timeout tasks, use Time to Live; otherwise purging the queue if there's an old task could case a new task to be discarded with it.



          You can set it with



          rabbitmqctl set_policy TTL ".*" '{"message-ttl":60000}' --apply-to queues


          and your queue will now discard tasks older than 1 minute.



          That said, there is a purge command in RMQ that you can just call on a timer.
          https://rabbitmq.github.io/rabbitmq-java-client/api/current/com/rabbitmq/client/AMQP.Queue.html






          share|improve this answer
























          • but i don't want all my queues to be cleared , only selected queues need to be cleared , that includes tickers , etc

            – Shersha Fn
            Nov 14 '18 at 10:20



















          1














          You can set time_limit for the task to kill it after a certain amount of time.
          Celery Time Limits



          @app.task(time_limit=60)
          def long_running_task():
          ...





          share|improve this answer
























          • Hi I added to the queue like this @celery_app_cron.task(time_limit=60,queue='ticker_queue') but nothing is happening

            – Shersha Fn
            Nov 14 '18 at 9:59











          • Does your task still execute after 60 seconds time limit?

            – oneor0
            Nov 14 '18 at 10:07











          • Yeah it is executing , after 60 seconds , all the pending queues are not cleared even after 60 seconds so task keeps on accumulating after evertime cron is run

            – Shersha Fn
            Nov 14 '18 at 10:16













          • I also tried expires=60 that also doesnt work

            – Shersha Fn
            Nov 14 '18 at 10:18











          • And also this is not what i want this kill the task that is currently executing the task greater than the time then it will kill that task , what i need is any task that is pending in the queue should be removed

            – Shersha Fn
            Nov 14 '18 at 12:23











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53294991%2fhow-do-i-periodically-purge-a-queue-in-celery-rabbitmq%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          If you need to timeout tasks, use Time to Live; otherwise purging the queue if there's an old task could case a new task to be discarded with it.



          You can set it with



          rabbitmqctl set_policy TTL ".*" '{"message-ttl":60000}' --apply-to queues


          and your queue will now discard tasks older than 1 minute.



          That said, there is a purge command in RMQ that you can just call on a timer.
          https://rabbitmq.github.io/rabbitmq-java-client/api/current/com/rabbitmq/client/AMQP.Queue.html






          share|improve this answer
























          • but i don't want all my queues to be cleared , only selected queues need to be cleared , that includes tickers , etc

            – Shersha Fn
            Nov 14 '18 at 10:20
















          1














          If you need to timeout tasks, use Time to Live; otherwise purging the queue if there's an old task could case a new task to be discarded with it.



          You can set it with



          rabbitmqctl set_policy TTL ".*" '{"message-ttl":60000}' --apply-to queues


          and your queue will now discard tasks older than 1 minute.



          That said, there is a purge command in RMQ that you can just call on a timer.
          https://rabbitmq.github.io/rabbitmq-java-client/api/current/com/rabbitmq/client/AMQP.Queue.html






          share|improve this answer
























          • but i don't want all my queues to be cleared , only selected queues need to be cleared , that includes tickers , etc

            – Shersha Fn
            Nov 14 '18 at 10:20














          1












          1








          1







          If you need to timeout tasks, use Time to Live; otherwise purging the queue if there's an old task could case a new task to be discarded with it.



          You can set it with



          rabbitmqctl set_policy TTL ".*" '{"message-ttl":60000}' --apply-to queues


          and your queue will now discard tasks older than 1 minute.



          That said, there is a purge command in RMQ that you can just call on a timer.
          https://rabbitmq.github.io/rabbitmq-java-client/api/current/com/rabbitmq/client/AMQP.Queue.html






          share|improve this answer













          If you need to timeout tasks, use Time to Live; otherwise purging the queue if there's an old task could case a new task to be discarded with it.



          You can set it with



          rabbitmqctl set_policy TTL ".*" '{"message-ttl":60000}' --apply-to queues


          and your queue will now discard tasks older than 1 minute.



          That said, there is a purge command in RMQ that you can just call on a timer.
          https://rabbitmq.github.io/rabbitmq-java-client/api/current/com/rabbitmq/client/AMQP.Queue.html







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 7:32









          TordekTordek

          7,03122861




          7,03122861













          • but i don't want all my queues to be cleared , only selected queues need to be cleared , that includes tickers , etc

            – Shersha Fn
            Nov 14 '18 at 10:20



















          • but i don't want all my queues to be cleared , only selected queues need to be cleared , that includes tickers , etc

            – Shersha Fn
            Nov 14 '18 at 10:20

















          but i don't want all my queues to be cleared , only selected queues need to be cleared , that includes tickers , etc

          – Shersha Fn
          Nov 14 '18 at 10:20





          but i don't want all my queues to be cleared , only selected queues need to be cleared , that includes tickers , etc

          – Shersha Fn
          Nov 14 '18 at 10:20













          1














          You can set time_limit for the task to kill it after a certain amount of time.
          Celery Time Limits



          @app.task(time_limit=60)
          def long_running_task():
          ...





          share|improve this answer
























          • Hi I added to the queue like this @celery_app_cron.task(time_limit=60,queue='ticker_queue') but nothing is happening

            – Shersha Fn
            Nov 14 '18 at 9:59











          • Does your task still execute after 60 seconds time limit?

            – oneor0
            Nov 14 '18 at 10:07











          • Yeah it is executing , after 60 seconds , all the pending queues are not cleared even after 60 seconds so task keeps on accumulating after evertime cron is run

            – Shersha Fn
            Nov 14 '18 at 10:16













          • I also tried expires=60 that also doesnt work

            – Shersha Fn
            Nov 14 '18 at 10:18











          • And also this is not what i want this kill the task that is currently executing the task greater than the time then it will kill that task , what i need is any task that is pending in the queue should be removed

            – Shersha Fn
            Nov 14 '18 at 12:23
















          1














          You can set time_limit for the task to kill it after a certain amount of time.
          Celery Time Limits



          @app.task(time_limit=60)
          def long_running_task():
          ...





          share|improve this answer
























          • Hi I added to the queue like this @celery_app_cron.task(time_limit=60,queue='ticker_queue') but nothing is happening

            – Shersha Fn
            Nov 14 '18 at 9:59











          • Does your task still execute after 60 seconds time limit?

            – oneor0
            Nov 14 '18 at 10:07











          • Yeah it is executing , after 60 seconds , all the pending queues are not cleared even after 60 seconds so task keeps on accumulating after evertime cron is run

            – Shersha Fn
            Nov 14 '18 at 10:16













          • I also tried expires=60 that also doesnt work

            – Shersha Fn
            Nov 14 '18 at 10:18











          • And also this is not what i want this kill the task that is currently executing the task greater than the time then it will kill that task , what i need is any task that is pending in the queue should be removed

            – Shersha Fn
            Nov 14 '18 at 12:23














          1












          1








          1







          You can set time_limit for the task to kill it after a certain amount of time.
          Celery Time Limits



          @app.task(time_limit=60)
          def long_running_task():
          ...





          share|improve this answer













          You can set time_limit for the task to kill it after a certain amount of time.
          Celery Time Limits



          @app.task(time_limit=60)
          def long_running_task():
          ...






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 7:36









          oneor0oneor0

          607617




          607617













          • Hi I added to the queue like this @celery_app_cron.task(time_limit=60,queue='ticker_queue') but nothing is happening

            – Shersha Fn
            Nov 14 '18 at 9:59











          • Does your task still execute after 60 seconds time limit?

            – oneor0
            Nov 14 '18 at 10:07











          • Yeah it is executing , after 60 seconds , all the pending queues are not cleared even after 60 seconds so task keeps on accumulating after evertime cron is run

            – Shersha Fn
            Nov 14 '18 at 10:16













          • I also tried expires=60 that also doesnt work

            – Shersha Fn
            Nov 14 '18 at 10:18











          • And also this is not what i want this kill the task that is currently executing the task greater than the time then it will kill that task , what i need is any task that is pending in the queue should be removed

            – Shersha Fn
            Nov 14 '18 at 12:23



















          • Hi I added to the queue like this @celery_app_cron.task(time_limit=60,queue='ticker_queue') but nothing is happening

            – Shersha Fn
            Nov 14 '18 at 9:59











          • Does your task still execute after 60 seconds time limit?

            – oneor0
            Nov 14 '18 at 10:07











          • Yeah it is executing , after 60 seconds , all the pending queues are not cleared even after 60 seconds so task keeps on accumulating after evertime cron is run

            – Shersha Fn
            Nov 14 '18 at 10:16













          • I also tried expires=60 that also doesnt work

            – Shersha Fn
            Nov 14 '18 at 10:18











          • And also this is not what i want this kill the task that is currently executing the task greater than the time then it will kill that task , what i need is any task that is pending in the queue should be removed

            – Shersha Fn
            Nov 14 '18 at 12:23

















          Hi I added to the queue like this @celery_app_cron.task(time_limit=60,queue='ticker_queue') but nothing is happening

          – Shersha Fn
          Nov 14 '18 at 9:59





          Hi I added to the queue like this @celery_app_cron.task(time_limit=60,queue='ticker_queue') but nothing is happening

          – Shersha Fn
          Nov 14 '18 at 9:59













          Does your task still execute after 60 seconds time limit?

          – oneor0
          Nov 14 '18 at 10:07





          Does your task still execute after 60 seconds time limit?

          – oneor0
          Nov 14 '18 at 10:07













          Yeah it is executing , after 60 seconds , all the pending queues are not cleared even after 60 seconds so task keeps on accumulating after evertime cron is run

          – Shersha Fn
          Nov 14 '18 at 10:16







          Yeah it is executing , after 60 seconds , all the pending queues are not cleared even after 60 seconds so task keeps on accumulating after evertime cron is run

          – Shersha Fn
          Nov 14 '18 at 10:16















          I also tried expires=60 that also doesnt work

          – Shersha Fn
          Nov 14 '18 at 10:18





          I also tried expires=60 that also doesnt work

          – Shersha Fn
          Nov 14 '18 at 10:18













          And also this is not what i want this kill the task that is currently executing the task greater than the time then it will kill that task , what i need is any task that is pending in the queue should be removed

          – Shersha Fn
          Nov 14 '18 at 12:23





          And also this is not what i want this kill the task that is currently executing the task greater than the time then it will kill that task , what i need is any task that is pending in the queue should be removed

          – Shersha Fn
          Nov 14 '18 at 12:23


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53294991%2fhow-do-i-periodically-purge-a-queue-in-celery-rabbitmq%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Xamarin.iOS Cant Deploy on Iphone

          Glorious Revolution

          Dulmage-Mendelsohn matrix decomposition in Python