How to handle asyncronous task queue in a server application? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to handle asyncronous task queue in a server application?

I am working on an api with flask which uses web scraping to supply data. suppose i have a function named update for the web scraping task which scapes the required data and caches the data in a database. How can I force the function to execute sequentially?

19th Mar 2020, 8:13 AM
Ishmam
Ishmam - avatar
4 Answers
+ 2
For handling asynchronous task queue in Flask, you can use Celery. http://www.celeryproject.org/ Here is an example : https://stackoverflow.com/questions/31866796/making-an-asynchronous-task-in-flask
19th Mar 2020, 1:20 PM
Gordon
Gordon - avatar
+ 2
sleep is not appropriate, because you cannot be sure how much time is needed for the response be fetched.
19th Mar 2020, 3:21 PM
Gordon
Gordon - avatar
+ 1
Gordon Oh that seems like a great solution. 😄 But, I am saying can I use a simpler time.sleep() in this case?
19th Mar 2020, 3:08 PM
Ishmam
Ishmam - avatar
0
Thanks for the response. 😊
19th Mar 2020, 3:24 PM
Ishmam
Ishmam - avatar