在Azure函数中返回生成器

问题描述 投票:0回答:1

是否可以在Azure函数中返回生成器?我正在尝试流式传输正在创建的数据。我没有运气就尝试了以下方法:def main(req: func.HttpRequest) -> func.HttpResponse: def gen(): for i in range(10): yield i return func.HttpResponse(gen(), mimetype='text/html')

以上产生TypeError: reponse is expected to be either of str, bytes, or bytearray, got generator。是否可以在Azure函数中执行类似的操作?我不一定要求它在Python中,但是它是首选。 

是否可以在Azure函数中返回生成器?我正在尝试在创建数据时流式传输数据。我没有运气尝试过以下命令:def main(req:func.HttpRequest)-> func ....

python azure stream azure-functions
1个回答
0
投票
我想这应该是可能的,请看一下example,您可能需要将响应转换为对象/字典。
© www.soinside.com 2019 - 2024. All rights reserved.