Celery connecting to rabbitmq-server instead of redis-server












2














I have a Django application which I want to configure it celery to run background tasks.



Packages:




  1. celery==4.2.1


  2. Django==2.1.3


  3. Python==3.5


  4. Redis-server==3.0.6



Configuration of celery in settings.py file is:



CELERY_BROKER_URL = 'redis://localhost:6379'

CELERY_RESULT_BACKEND = 'redis://localhost:6379'
CELERY_ACCEPT_CONTENT = ['application/json']
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_SERIALIZER = 'json'
CELERY_TIMEZONE = 'Asia/Kolkata'
CELERY_BEAT_SCHEDULE = {
'task-number-one': {
'task': 'app.tasks.task_number_one',
'schedule': crontab(minute='*/1'),
},
}


And celery.py file:



from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
from django.conf import settings
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings.prod')

app = Celery('project')

# Using a string here means the worker don't have to serialize
# the configuration object to child processes.
# - namespace='CELERY' means all celery-related configuration keys
# should have a `CELERY_` prefix.
app.config_from_object('django.conf:settings')

# Load task modules from all registered Django app configs.
app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)


@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))


When I run : celery -A project worker -l info -B -E



It points to rabmmitmq server, instead it should point to redis-server, shown below:



 -------------- celery@user-desktop v4.2.1 (windowlicker)
---- **** -----
--- * *** * -- Linux-4.15.0-39-generic-x86_64-with-Ubuntu-18.04-bionic 2018-11-21 12:04:51
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: project:0x7f8b80f78d30
- ** ---------- .> transport: amqp://guest:**@localhost:5672//
- ** ---------- .> results: redis://localhost:6379/
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ---- .> task events: ON
--- ***** -----
-------------- [queues]
.> celery exchange=celery(direct) key=celery


[tasks]
. app.tasks.task_number_one
. project.celery.debug_task

[2018-11-21 12:04:51,741: INFO/Beat] beat: Starting...


The same happend in production enviornment.
In production I have deployed the Django application with Gunicorn and Nginx, and now I want to implement some method to run background tasks, as django-crontab package is not working.




Problem:




  1. What is the problem with celery configuration?


  2. Could anyone please recommend a method to run periodic background task?





**Note: I have tried implementing supervisor, but it seems supervisor is not compatible with python3, and therefore could not configure it.










share|improve this question





























    2














    I have a Django application which I want to configure it celery to run background tasks.



    Packages:




    1. celery==4.2.1


    2. Django==2.1.3


    3. Python==3.5


    4. Redis-server==3.0.6



    Configuration of celery in settings.py file is:



    CELERY_BROKER_URL = 'redis://localhost:6379'

    CELERY_RESULT_BACKEND = 'redis://localhost:6379'
    CELERY_ACCEPT_CONTENT = ['application/json']
    CELERY_RESULT_SERIALIZER = 'json'
    CELERY_TASK_SERIALIZER = 'json'
    CELERY_TIMEZONE = 'Asia/Kolkata'
    CELERY_BEAT_SCHEDULE = {
    'task-number-one': {
    'task': 'app.tasks.task_number_one',
    'schedule': crontab(minute='*/1'),
    },
    }


    And celery.py file:



    from __future__ import absolute_import, unicode_literals
    import os
    from celery import Celery
    from django.conf import settings
    # set the default Django settings module for the 'celery' program.
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings.prod')

    app = Celery('project')

    # Using a string here means the worker don't have to serialize
    # the configuration object to child processes.
    # - namespace='CELERY' means all celery-related configuration keys
    # should have a `CELERY_` prefix.
    app.config_from_object('django.conf:settings')

    # Load task modules from all registered Django app configs.
    app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)


    @app.task(bind=True)
    def debug_task(self):
    print('Request: {0!r}'.format(self.request))


    When I run : celery -A project worker -l info -B -E



    It points to rabmmitmq server, instead it should point to redis-server, shown below:



     -------------- celery@user-desktop v4.2.1 (windowlicker)
    ---- **** -----
    --- * *** * -- Linux-4.15.0-39-generic-x86_64-with-Ubuntu-18.04-bionic 2018-11-21 12:04:51
    -- * - **** ---
    - ** ---------- [config]
    - ** ---------- .> app: project:0x7f8b80f78d30
    - ** ---------- .> transport: amqp://guest:**@localhost:5672//
    - ** ---------- .> results: redis://localhost:6379/
    - *** --- * --- .> concurrency: 4 (prefork)
    -- ******* ---- .> task events: ON
    --- ***** -----
    -------------- [queues]
    .> celery exchange=celery(direct) key=celery


    [tasks]
    . app.tasks.task_number_one
    . project.celery.debug_task

    [2018-11-21 12:04:51,741: INFO/Beat] beat: Starting...


    The same happend in production enviornment.
    In production I have deployed the Django application with Gunicorn and Nginx, and now I want to implement some method to run background tasks, as django-crontab package is not working.




    Problem:




    1. What is the problem with celery configuration?


    2. Could anyone please recommend a method to run periodic background task?





    **Note: I have tried implementing supervisor, but it seems supervisor is not compatible with python3, and therefore could not configure it.










    share|improve this question



























      2












      2








      2







      I have a Django application which I want to configure it celery to run background tasks.



      Packages:




      1. celery==4.2.1


      2. Django==2.1.3


      3. Python==3.5


      4. Redis-server==3.0.6



      Configuration of celery in settings.py file is:



      CELERY_BROKER_URL = 'redis://localhost:6379'

      CELERY_RESULT_BACKEND = 'redis://localhost:6379'
      CELERY_ACCEPT_CONTENT = ['application/json']
      CELERY_RESULT_SERIALIZER = 'json'
      CELERY_TASK_SERIALIZER = 'json'
      CELERY_TIMEZONE = 'Asia/Kolkata'
      CELERY_BEAT_SCHEDULE = {
      'task-number-one': {
      'task': 'app.tasks.task_number_one',
      'schedule': crontab(minute='*/1'),
      },
      }


      And celery.py file:



      from __future__ import absolute_import, unicode_literals
      import os
      from celery import Celery
      from django.conf import settings
      # set the default Django settings module for the 'celery' program.
      os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings.prod')

      app = Celery('project')

      # Using a string here means the worker don't have to serialize
      # the configuration object to child processes.
      # - namespace='CELERY' means all celery-related configuration keys
      # should have a `CELERY_` prefix.
      app.config_from_object('django.conf:settings')

      # Load task modules from all registered Django app configs.
      app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)


      @app.task(bind=True)
      def debug_task(self):
      print('Request: {0!r}'.format(self.request))


      When I run : celery -A project worker -l info -B -E



      It points to rabmmitmq server, instead it should point to redis-server, shown below:



       -------------- celery@user-desktop v4.2.1 (windowlicker)
      ---- **** -----
      --- * *** * -- Linux-4.15.0-39-generic-x86_64-with-Ubuntu-18.04-bionic 2018-11-21 12:04:51
      -- * - **** ---
      - ** ---------- [config]
      - ** ---------- .> app: project:0x7f8b80f78d30
      - ** ---------- .> transport: amqp://guest:**@localhost:5672//
      - ** ---------- .> results: redis://localhost:6379/
      - *** --- * --- .> concurrency: 4 (prefork)
      -- ******* ---- .> task events: ON
      --- ***** -----
      -------------- [queues]
      .> celery exchange=celery(direct) key=celery


      [tasks]
      . app.tasks.task_number_one
      . project.celery.debug_task

      [2018-11-21 12:04:51,741: INFO/Beat] beat: Starting...


      The same happend in production enviornment.
      In production I have deployed the Django application with Gunicorn and Nginx, and now I want to implement some method to run background tasks, as django-crontab package is not working.




      Problem:




      1. What is the problem with celery configuration?


      2. Could anyone please recommend a method to run periodic background task?





      **Note: I have tried implementing supervisor, but it seems supervisor is not compatible with python3, and therefore could not configure it.










      share|improve this question















      I have a Django application which I want to configure it celery to run background tasks.



      Packages:




      1. celery==4.2.1


      2. Django==2.1.3


      3. Python==3.5


      4. Redis-server==3.0.6



      Configuration of celery in settings.py file is:



      CELERY_BROKER_URL = 'redis://localhost:6379'

      CELERY_RESULT_BACKEND = 'redis://localhost:6379'
      CELERY_ACCEPT_CONTENT = ['application/json']
      CELERY_RESULT_SERIALIZER = 'json'
      CELERY_TASK_SERIALIZER = 'json'
      CELERY_TIMEZONE = 'Asia/Kolkata'
      CELERY_BEAT_SCHEDULE = {
      'task-number-one': {
      'task': 'app.tasks.task_number_one',
      'schedule': crontab(minute='*/1'),
      },
      }


      And celery.py file:



      from __future__ import absolute_import, unicode_literals
      import os
      from celery import Celery
      from django.conf import settings
      # set the default Django settings module for the 'celery' program.
      os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings.prod')

      app = Celery('project')

      # Using a string here means the worker don't have to serialize
      # the configuration object to child processes.
      # - namespace='CELERY' means all celery-related configuration keys
      # should have a `CELERY_` prefix.
      app.config_from_object('django.conf:settings')

      # Load task modules from all registered Django app configs.
      app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)


      @app.task(bind=True)
      def debug_task(self):
      print('Request: {0!r}'.format(self.request))


      When I run : celery -A project worker -l info -B -E



      It points to rabmmitmq server, instead it should point to redis-server, shown below:



       -------------- celery@user-desktop v4.2.1 (windowlicker)
      ---- **** -----
      --- * *** * -- Linux-4.15.0-39-generic-x86_64-with-Ubuntu-18.04-bionic 2018-11-21 12:04:51
      -- * - **** ---
      - ** ---------- [config]
      - ** ---------- .> app: project:0x7f8b80f78d30
      - ** ---------- .> transport: amqp://guest:**@localhost:5672//
      - ** ---------- .> results: redis://localhost:6379/
      - *** --- * --- .> concurrency: 4 (prefork)
      -- ******* ---- .> task events: ON
      --- ***** -----
      -------------- [queues]
      .> celery exchange=celery(direct) key=celery


      [tasks]
      . app.tasks.task_number_one
      . project.celery.debug_task

      [2018-11-21 12:04:51,741: INFO/Beat] beat: Starting...


      The same happend in production enviornment.
      In production I have deployed the Django application with Gunicorn and Nginx, and now I want to implement some method to run background tasks, as django-crontab package is not working.




      Problem:




      1. What is the problem with celery configuration?


      2. Could anyone please recommend a method to run periodic background task?





      **Note: I have tried implementing supervisor, but it seems supervisor is not compatible with python3, and therefore could not configure it.







      django celery background-process redis-server






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 21 '18 at 6:58







      Reema Parakh

















      asked Nov 21 '18 at 6:51









      Reema ParakhReema Parakh

      396112




      396112
























          2 Answers
          2






          active

          oldest

          votes


















          1














          The setting for the broker url changed in v4. It should be BROKER_URL and not CELERY_BROKER_URL.






          share|improve this answer





























            0














            To make celery work with redis, You have to install additional dependencies.



            pip install -U "celery[redis]"


            Please go through the celery documentation.






            share|improve this answer





















            • I did this, but its not working.
              – Reema Parakh
              Nov 21 '18 at 11:52











            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%2f53406661%2fcelery-connecting-to-rabbitmq-server-instead-of-redis-server%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














            The setting for the broker url changed in v4. It should be BROKER_URL and not CELERY_BROKER_URL.






            share|improve this answer


























              1














              The setting for the broker url changed in v4. It should be BROKER_URL and not CELERY_BROKER_URL.






              share|improve this answer
























                1












                1








                1






                The setting for the broker url changed in v4. It should be BROKER_URL and not CELERY_BROKER_URL.






                share|improve this answer












                The setting for the broker url changed in v4. It should be BROKER_URL and not CELERY_BROKER_URL.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 22 '18 at 5:51









                2ps2ps

                7,4022930




                7,4022930

























                    0














                    To make celery work with redis, You have to install additional dependencies.



                    pip install -U "celery[redis]"


                    Please go through the celery documentation.






                    share|improve this answer





















                    • I did this, but its not working.
                      – Reema Parakh
                      Nov 21 '18 at 11:52
















                    0














                    To make celery work with redis, You have to install additional dependencies.



                    pip install -U "celery[redis]"


                    Please go through the celery documentation.






                    share|improve this answer





















                    • I did this, but its not working.
                      – Reema Parakh
                      Nov 21 '18 at 11:52














                    0












                    0








                    0






                    To make celery work with redis, You have to install additional dependencies.



                    pip install -U "celery[redis]"


                    Please go through the celery documentation.






                    share|improve this answer












                    To make celery work with redis, You have to install additional dependencies.



                    pip install -U "celery[redis]"


                    Please go through the celery documentation.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 21 '18 at 8:34









                    Dinesh MandepudiDinesh Mandepudi

                    261




                    261












                    • I did this, but its not working.
                      – Reema Parakh
                      Nov 21 '18 at 11:52


















                    • I did this, but its not working.
                      – Reema Parakh
                      Nov 21 '18 at 11:52
















                    I did this, but its not working.
                    – Reema Parakh
                    Nov 21 '18 at 11:52




                    I did this, but its not working.
                    – Reema Parakh
                    Nov 21 '18 at 11:52


















                    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.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • 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%2f53406661%2fcelery-connecting-to-rabbitmq-server-instead-of-redis-server%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

                    Costa Masnaga

                    Fotorealismo

                    Sidney Franklin