Context manager installs ``connection`` as the session context for the current Trio task.
(connection)
| 107 | |
| 108 | @contextmanager |
| 109 | def connection_context(connection): |
| 110 | """Context manager installs ``connection`` as the session context for the current Trio task.""" |
| 111 | token = _connection_context.set(connection) |
| 112 | try: |
| 113 | yield |
| 114 | finally: |
| 115 | _connection_context.reset(token) |
| 116 | |
| 117 | |
| 118 | @contextmanager |