I got Flask application written in python 3.6.
On registration there is created user and synchronization with external service is done (takes ~5s).
class Register(Resource):
def post(self):
submitted_data = flask.request.get_json(force=True)
user = User.register(submitted_data)
# long-running API calls
user.synchronize_with_external_service()
return {}, 201
User
is SQLALchemy model. During synchronize_with_external_service
external service is called and some fields in db are updated. Due to this synchronization taking long time I would like to do it asynchronously and response user immediately. I thought about celery, asyncio or multi-threading to do it, but I would like to know which option is best.
Application is setup on AWS Elasticbean (load balancing, 2 instances, multi-docker).