I am in process of building a small utility using Flask and python(ver 3.6).
This utility is basically calling external systems (sys1 and sys2) using REST calls and synching data unidirectionally from sys1 to sys2. This synch process will run continuously till a kill flag is set.
I want the ability to start and stop this synch process/method using flask routes.
for example,
- if a request is received at /start,
o Then start then start this method.
o return a HTTP response code (the response should not wait for method to complete) - if a request is received at /stop, o if the method is running, stop the method by setting kill flag. (here again, the response from flask should not wait for method to complete)
Now,I went though many of the queries here and other sites but they all seem to cater to specific needs. Based on my understanding, I have tried the following things (may be improperly to achieve this task:
Tried creating a thread from the route and call the method - Didn't work as for some reason flask waited for the method to complete (is it because flask is single threaded and blocking ?)
Read up on celery but i feel it may be an overkill to use celery in this case.
What would be a correct way to start this process asynchronously & how? Threads ? asyncio or Celery is the only way.