Look up the current connection. If there is no current connection, raise a ``RuntimeError`` with a helpful message.
(fn_name)
| 82 | |
| 83 | |
| 84 | def get_connection_context(fn_name): |
| 85 | """Look up the current connection. |
| 86 | |
| 87 | If there is no current connection, raise a ``RuntimeError`` with a |
| 88 | helpful message. |
| 89 | """ |
| 90 | try: |
| 91 | return _connection_context.get() |
| 92 | except LookupError: |
| 93 | raise RuntimeError(f"{fn_name}() must be called in a connection context.") from None |
| 94 | |
| 95 | |
| 96 | def get_session_context(fn_name): |