Flask how to make a call without waiting for his answer to return a response in jsonify?

0 like 0 dislike
11 views
There is a route, if a request whose method should be called draw() which in turn draws the picture using the Pillow library.
The problem is that all the rendering takes about 10 seconds (especially the drivers of e-ink display)

from draw import Drawing @app.route(api_url('/'), methods=['POST']) def router(route): try: req_data = request.json if route == 'weather': Drawing().draw() return jsonify(status='Draw'), 200 else: return abort(404) except Exception as e: logError(e) return abort(400)

The question is how to call a method to start rendering and not waiting for an answer this method to return the response in json?
by | 11 views

2 Answers

0 like 0 dislike
It is necessary to separate flies from cutlets.
In the roat erect the flag "need redraw". A separate thread (or even better - a separate service) monitor this flag and react accordingly. Otherwise you're in trouble as soon as the router will treat more than 1 client.
by
0 like 0 dislike
Asynchron on the basis of queues of radishes is not an option? I'm talking about something like this.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
0 like 0 dislike
2 answers
110,608 questions
257,186 answers
0 comments
28,742 users