title: Unsure how to run Celery under windows for periodic tasks
body: <p>I am having difficulty understanding how to run Celery after setting up some scheduled tasks. </p>
  
  <p>Firstly, my project directory is structured as follows:</p>
  
  <p><a href="https://i.stack.imgur.com/AwGsB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AwGsB.png" alt="enter image description here"></a></p>
  
  <p><strong><code>blogpodapi\api\__init__.py</code></strong> contains</p>
  
  <pre><code>from tasks import app
  import celeryconfig
  </code></pre>
  
  <p><strong><code>blogpodapi\api\celeryconfig.py</code></strong> contains</p>
  
  <pre><code>from datetime import timedelta
  
  # Celery settings
  CELERY_BROKER_URL = 'redis://localhost:6379/0'
  BROKER_URL = 'redis://localhost:6379/0'
  CELERY_RESULT_BACKEND = 'redis://localhost:6379/1'
  CELERY_ACCEPT_CONTENT = ['application/json']
  CELERY_TASK_SERIALIZER = 'json'
  CELERY_RESULT_SERIALIZER = 'json'
  CELERY_TIMEZONE = 'UTC'
  CELERY_IMPORTS = ("api.tasks",)
  
  CELERYBEAT_SCHEDULE = {
      'write-test': {
          'task': 'api.tasks.addrandom',
          'schedule': timedelta(seconds=2),
          'args': (16000, 42)
      },
  }
  </code></pre>
  
  <p><strong><code>blogpodapi\api\tasks.py</code></strong> contains</p>
  
  <pre><code>from __future__ import absolute_import
  import random
  from celery import Celery
  app = Celery('blogpodapi')
  
  
  @app.task
  def add(x, y):
      r = x + y
      print "task arguments: {x}, {y}".format(x=x, y=y)
      print "task result: {r}".format(r=r)
      return r
  
  
  @app.task
  def addrandom(x, *args): # *args are not used, just there to be interchangable with add(x, y)
      y = random.randint(1,100)
      print "passing to add(x, y)"
      return add(x, y)
  </code></pre>
  
  <p><strong><code>blogpodapi\blogpodapi\__init__.py</code></strong> contains</p>
  
  <pre><code>from __future__ import absolute_import
  
  # This will make sure the app is always imported when
  # Django starts so that shared_task will use this app.
  from .celery import app as celery_app  # noqa
  </code></pre>
  
  <p><strong><code>blogpodapi\blogpodapi\settings.py</code></strong> contains</p>
  
  <pre><code>...
  
  # Celery settings
  CELERY_BROKER_URL = 'redis://localhost:6379/0'
  BROKER_URL = 'redis://localhost:6379/0'
  CELERY_RESULT_BACKEND = 'redis://localhost:6379/1'
  CELERY_ACCEPT_CONTENT = ['application/json']
  CELERY_TASK_SERIALIZER = 'json'
  CELERY_RESULT_SERIALIZER = 'json'
  CELERY_TIMEZONE = 'UTC'
  CELERY_IMPORTS = ("api.tasks",)
  
  ...
  </code></pre>
  
  <p>I run <code>celery -A blogpodapi worker --loglevel=info</code> in command prompt and get the following:</p>
  
  <pre><code>D:\blogpodapi&gt;celery -A blogpodapi worker --loglevel=info
  
   -------------- celery@JM v3.1.23 (Cipater)
  ---- **** -----
  --- * ***  * -- Windows-8-6.2.9200
  -- * - **** ---
  - ** ---------- [config]
  - ** ---------- .&gt; app:         blogpodapi:0x348a940
  - ** ---------- .&gt; transport:   redis://localhost:6379/0
  - ** ---------- .&gt; results:     redis://localhost:6379/1
  - *** --- * --- .&gt; concurrency: 2 (prefork)
  -- ******* ----
  --- ***** ----- [queues]
   -------------- .&gt; celery           exchange=celery(direct) key=celery
  
  
  [tasks]
    . api.tasks.add
    . api.tasks.addrandom
    . blogpodapi.celery.debug_task
  
  [2016-08-13 13:01:51,108: INFO/MainProcess] Connected to redis://localhost:6379/0
  [2016-08-13 13:01:52,122: INFO/MainProcess] mingle: searching for neighbors
  [2016-08-13 13:01:55,138: INFO/MainProcess] mingle: all alone
  c:\python27\lib\site-packages\celery\fixups\django.py:265: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
    warnings.warn('Using settings.DEBUG leads to a memory leak, never '
  
  [2016-08-13 13:02:00,157: WARNING/MainProcess] c:\python27\lib\site-packages\celery\fixups\django.py:265: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
    warnings.warn('Using settings.DEBUG leads to a memory leak, never '
  
  [2016-08-13 13:02:27,790: WARNING/MainProcess] celery@JM ready.
  </code></pre>
  
  <p>I then run <code>celery -A blogpodapi beat</code> in command prompt and get the following:</p>
  
  <pre><code>D:\blogpodapi&gt;celery -A blogpodapi beat
  celery beat v3.1.23 (Cipater) is starting.
  __    -    ... __   -        _
  Configuration -&gt;
      . broker -&gt; redis://localhost:6379/0
      . loader -&gt; celery.loaders.app.AppLoader
      . scheduler -&gt; celery.beat.PersistentScheduler
      . db -&gt; celerybeat-schedule
      . logfile -&gt; [stderr]@%INFO
      . maxinterval -&gt; now (0s)
  [2016-08-13 13:02:51,937: INFO/MainProcess] beat: Starting...
  </code></pre>
  
  <p>For some reason, I can't seem to view my periodic tasks being logged. Is there anything I am doing wrong?</p>
  
  <p><strong>UPDATE: here is my celery.py...</strong></p>
  
  <pre><code>from __future__ import absolute_import
  import os
  from celery import Celery
  
  # set the default Django settings module for the 'celery' program.
  os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'blogpodapi.settings')
  
  from django.conf import settings  # noqa
  
  app = Celery('blogpodapi')
  
  # Using a string here means the worker will not have to
  # pickle the object when using Windows.
  app.config_from_object('django.conf:settings')
  app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
  
  
  @app.task(bind=True)
  def debug_task(self):
      print('Request: {0!r}'.format(self.request))
  </code></pre>