You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am making an adapter for running ASGI applications in GCP Cloud Function. (Repo)
Simply, I want to run my ASGI application (such as FastAPI or Django) in Cloud Function.
I confirmed that my adapter (vellox) works "hello world" example properly. But functions_framework throw error when handler is not types.FunctionType. In abvoe code, handler is instance of Vellox and also it is callable.
The code below is the part that is problematic.
# src/functions_framework/_function_registry.pydefget_user_function(source, source_module, target):
"""Returns user function, raises exception for invalid function."""# . . .function=getattr(source_module, target)
# Check that it is a functionifnotisinstance(function, types.FunctionType):
raiseInvalidTargetTypeException(
"The function defined in file {source} as '{target}' needs to be of ""type function. Got: invalid type {target_type}".format(
source=source, target=target, target_type=type(function)
)
)
returnfunction
Instead of forcing the function type to be function, I suggest changing it to Callable, which has a slightly wider scope.
The text was updated successfully, but these errors were encountered:
In the get_user_function function within _function_registry.py, change the type check to accept callable objects instead of only types.FunctionType. This allows for instances of classes with a __call__ method.
I am making an adapter for running ASGI applications in GCP Cloud Function. (Repo)
Simply, I want to run my ASGI application (such as FastAPI or Django) in Cloud Function.
My adapter(
Vellox
) works like this:I confirmed that my adapter (vellox) works "hello world" example properly. But
functions_framework
throw error when handler is nottypes.FunctionType
. In abvoe code, handler is instance ofVellox
and also it is callable.The code below is the part that is problematic.
Instead of forcing the function type to be function, I suggest changing it to
Callable
, which has a slightly wider scope.The text was updated successfully, but these errors were encountered: