Description
Dear maintainers,
I wrote my template that is similar to https://github.com/openfaas-incubator/python-flask-template/tree/master/template/python3-flask.
The different from the original is that my template uses stream response (or, chunked response) as follows.
@app.route("/", defaults={"path": ""}, methods=["POST", "GET"])
@app.route("/<path:path>", methods=["POST", "GET"])
def main_route(path):
...
def gen():
yield "1"
time.sleep(1)
yield "2"
time.sleep(1)
yield "3"
return Response(gen())
When I invoke a function from the template, the function does not return response chunk by chunk.
It blocks 3 seconds, and then, returns whole the response (1, 2 and 3) all at once.
Expected Behaviour
Function returns response chunk by chunk.
Current Behaviour
Function blocks 3 seconds, and then, returns whole the response all at once.
Possible Solution
The following code blocks until whole the response returned.
And openfaas/faas's following code also blocks, maybe.
Steps to Reproduce (for bugs)
- fetch this template https://github.com/openfaas-incubator/python-flask-template/tree/master/template/python3-flask
- edit the template as described above
- create new function from the template
- build, push, deploy and invoke the function
Your Environment
Docker version 18.09.1, build 4c52b90
Docker swarm
Linux (vagrant, vm.box = "bento/centos-7.4")
Thank you.