@@ -215,6 +215,29 @@ async def __call__(self, scope, receive, send):
215215 # Don't re-raise to prevent starlette from printing traceback again
216216
217217
218+ def create_asgi_app_from_module (target , source , signature_type , source_module , spec ):
219+ """Create an ASGI application from an already-loaded module.
220+
221+ Args:
222+ target: The name of the target function to invoke
223+ source: The source file containing the function
224+ signature_type: The signature type of the function
225+ source_module: The already-loaded module
226+ spec: The module spec
227+
228+ Returns:
229+ A Starlette ASGI application instance
230+ """
231+ enable_id_logging = _enable_execution_id_logging ()
232+ if enable_id_logging :
233+ _configure_app_execution_id_logging ()
234+
235+ function = _function_registry .get_user_function (source , source_module , target )
236+ signature_type = _function_registry .get_func_signature_type (target , signature_type )
237+
238+ return _create_asgi_app_with_function (function , signature_type , enable_id_logging )
239+
240+
218241def create_asgi_app (target = None , source = None , signature_type = None ):
219242 """Create an ASGI application for the function.
220243
@@ -245,6 +268,11 @@ def create_asgi_app(target=None, source=None, signature_type=None):
245268 function = _function_registry .get_user_function (source , source_module , target )
246269 signature_type = _function_registry .get_func_signature_type (target , signature_type )
247270
271+ return _create_asgi_app_with_function (function , signature_type , enable_id_logging )
272+
273+
274+ def _create_asgi_app_with_function (function , signature_type , enable_id_logging ):
275+ """Create an ASGI app with the given function and signature type."""
248276 is_async = inspect .iscoroutinefunction (function )
249277 routes = []
250278 if signature_type == _function_registry .HTTP_SIGNATURE_TYPE :
0 commit comments