GoogleCloudPlatform / GoogleCloudPlatform/functions-framework-python

support of async views

Ouverte
#192 3 commentaires 11 réactions 1 personne assignée Réclamée par @jama22 Voir sur GitHub
enhancement
Langage dominant
Python
Étoiles
968
Forks
128
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

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

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.