GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-python

support of async views

Abierto
#192 3 comentarios 11 reacciones 1 asignado Reclamado por @jama22 Ver en GitHub
enhancement
Lenguaje dominante
Python
Estrellas
968
Forks
128
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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`).

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.