MCPcopy
hub / github.com/pallets/jinja / make_module_async

Method make_module_async

src/jinja2/environment.py:1407–1423  ·  view source on GitHub ↗

As template module creation can invoke template code for asynchronous executions this method must be used instead of the normal :meth:`make_module` one. Likewise the module attribute becomes unavailable in async mode.

(
        self,
        vars: t.Optional[t.Dict[str, t.Any]] = None,
        shared: bool = False,
        locals: t.Optional[t.Mapping[str, t.Any]] = None,
    )

Source from the content-addressed store, hash-verified

1405 return TemplateModule(self, ctx)
1406
1407 async def make_module_async(
1408 self,
1409 vars: t.Optional[t.Dict[str, t.Any]] = None,
1410 shared: bool = False,
1411 locals: t.Optional[t.Mapping[str, t.Any]] = None,
1412 ) -> "TemplateModule":
1413 """As template module creation can invoke template code for
1414 asynchronous executions this method must be used instead of the
1415 normal :meth:`make_module` one. Likewise the module attribute
1416 becomes unavailable in async mode.
1417 """
1418 ctx = self.new_context(vars, shared, locals)
1419 return TemplateModule(
1420 self,
1421 ctx,
1422 [x async for x in self.root_render_func(ctx)], # type: ignore
1423 )
1424
1425 @internalcode
1426 def _get_default_module(self, ctx: t.Optional[Context] = None) -> "TemplateModule":

Callers 1

Calls 2

new_contextMethod · 0.95
TemplateModuleClass · 0.85

Tested by

no test coverage detected