title: How to run a function periodically with Flask and Celery?
body: <p>I have a flask app that roughly looks like this:</p>
  
  <pre><code>app = Flask(__name__)
  @app.route('/',methods=['POST'])
  def foo():
     data = json.loads(request.data)
     # do some stuff
  
     return "OK"
  </code></pre>
  
  <p>Now in addition I would like to run a function every ten seconds from that script. I don't want to use sleep for that. I have the following celery script in addition:</p>
  
  <pre><code>from celery import Celery
  from datetime import timedelta
  celery = Celery('__name__')
  
  CELERYBEAT_SCHEDULE = {
      'add-every-30-seconds': {
          'task': 'tasks.add',
          'schedule': timedelta(seconds=10)
      },
  }
  
  
  
  @celery.task(name='tasks.add')
  def hello():
      app.logger.info('run my function')
  </code></pre>
  
  <p>The script works fine, but the logger.info is not executed. What am I missing?</p>