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 摘要。