Closed ddurieux closed 8 years ago
I think you should use with with app.app_context():
Is this code a unit test? If so, why do you need a Flask App?
Could you provide me a full example?
Thanks!
I have found a solution, so I think we can close this ;)
@ddurieux would have been helpful if you could have shared your solution before closing the issue.. thanks.
@ddurieux please share the solution. Thank you
Yep, sorry for the delay,
I add jobs in config and load the config by eve: https://github.com/Alignak-monitoring-contrib/alignak-backend/blob/develop/alignak_backend/app.py#L1829-L1874
I have a file with the scheduler functions: https://github.com/Alignak-monitoring-contrib/alignak-backend/blob/develop/alignak_backend/scheduler.py
@ddurieux Thank you
This was not really helpful, let me explain it my way:
You should expose your APP as variable in one of your application module. For instance, in your app.py
you don't expose a create_app()
but a live app instance instead.
Then you do a local import of this application in your scheduled function:
def job1():
from mylib.app import app
app.logger.error('FUFU!')
At the moment i try to understand if it is not better to call with app.application_context():
Anyway this solution is simple.
I was using request.post, request.put instead of requests.post, requests.put.
With flask, I use mongo database and my scheduler job use this mongo, but i have error
When I use call function, I use
But here not possible to works. Do you know how to fix this problem?