GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-python

support of async views

未关闭
#192 3 条评论 11 个 reaction 已指派 1 人 已被 @jama22 认领 在 GitHub 查看
enhancement
主要语言
Python
星标
968
派生
128
PR 合并指标
30 天内没有已合并 PR

描述

Similarly to Flask, the framework should support `async` function for a view - see https://flask.palletsprojects.com/en/2.1.x/async-await/
Under the hood, Flask executes `asyncio.run()` and returns the resulting value to the client.

When trying to define the view function with `async`, one gets `TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a coroutine.`

Workaround is simply to create a "regular" sync function that executes (`asyncio.run()`) a separate async function but it could be simpler and match Flask functionality.

Our use case: use Google Cloud Functions from BigQuery Remote Function to call external APIs concurrently (using `aiohttp`).

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。