MCPcopy Index your code
hub / github.com/tortoise/tortoise-orm / require_context

Function require_context

tortoise/context.py:99–116  ·  view source on GitHub ↗

Get the currently active TortoiseContext, raising if none is active. Returns: The current TortoiseContext. Raises: RuntimeError: If no TortoiseContext is currently active.

()

Source from the content-addressed store, hash-verified

97
98
99def require_context() -> TortoiseContext:
100 """
101 Get the currently active TortoiseContext, raising if none is active.
102
103 Returns:
104 The current TortoiseContext.
105
106 Raises:
107 RuntimeError: If no TortoiseContext is currently active.
108 """
109 ctx = get_current_context()
110 if ctx is None:
111 raise RuntimeError(
112 "No TortoiseContext is currently active. "
113 "Use 'async with TortoiseContext() as ctx:' to create one, "
114 "or call Tortoise.init() for global state."
115 )
116 return ctx
117
118
119class TortoiseContext:

Calls 1

get_current_contextFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…