Get the current request context, raising an error if not available. Returns: The current RequestContext. Raises: RuntimeError: If called outside of a request context.
()
| 186 | |
| 187 | |
| 188 | def require_context() -> RequestContext: |
| 189 | """ |
| 190 | Get the current request context, raising an error if not available. |
| 191 | |
| 192 | Returns: |
| 193 | The current RequestContext. |
| 194 | |
| 195 | Raises: |
| 196 | RuntimeError: If called outside of a request context. |
| 197 | """ |
| 198 | context = get_current_context() |
| 199 | if context is None: |
| 200 | raise RuntimeError( |
| 201 | "No request context available. This function must be called within a request handler." |
| 202 | ) |
| 203 | return context |
| 204 | |
| 205 | |
| 206 | class ContextThread(threading.Thread): |
nothing calls this directly
no test coverage detected