Python, Celery, Flask, “working outside of application context”

前端 未结 1 1507
眼角桃花
眼角桃花 2021-01-29 11:03

I am trying to schedule tasks using Celery and Python for a Flask app. I basically want to run a function in another directory every x amount of time and make it a celery task.

1条回答
  •  闹比i
    闹比i (楼主)
    2021-01-29 11:27

    Whatever test_check is, it does something that needs a request context. Since Celery tasks are not part of the HTTP request/response cycle, you need to set up a request context manually.

    with app.test_request_context():
        test_check()
    

    0 讨论(0)
提交回复
热议问题