Look up the current session. If there is no current session, raise a ``RuntimeError`` with a helpful message.
(fn_name)
| 94 | |
| 95 | |
| 96 | def get_session_context(fn_name): |
| 97 | """Look up the current session. |
| 98 | |
| 99 | If there is no current session, raise a ``RuntimeError`` with a |
| 100 | helpful message. |
| 101 | """ |
| 102 | try: |
| 103 | return _session_context.get() |
| 104 | except LookupError: |
| 105 | raise RuntimeError(f"{fn_name}() must be called in a session context.") from None |
| 106 | |
| 107 | |
| 108 | @contextmanager |