Reputation: 1
I have built a "Large" application using Flask-AppBuilder and have 2 questions I have not seen the answer to.
Any examples of either of these would be lovely.
Upvotes: 0
Views: 478
Reputation: 599
it does not really matter what framework you use, but as soon as the application grows you may want to isolate critical logic. Both for the reasons you described above, but also to be future-proof (you may want to move to a new frontend in the future without rewrite the heavy lifting).
I ususally set up a redis worker for this, and use e.g. flask only to trigger the queue with function calls. That also makes the application more scalable (concurrent users, more data) as you can simply start more workers listening to your queue if needed.
In essence:
from redis import Redis
from rq import Queue
from rq.job import Job
conn = Redis()
q = Queue(connection=conn)
Then as example in the flask routes (for appBuilder, use the views, or create your own lib) call:
result = q.enqueue('utils.your_function_name',args=(id,))
Have a look at RQ here for more examples, also how to monitor the status of your jobs etc.
Upvotes: 0