Hold the lock until the context exits. See :meth:`acquire_read` for acquisition errors. :param timeout: seconds to wait, or ``None`` for the instance default :param blocking: wait on contention, or ``None`` for the instance default :yields: while the lock is held
(self, timeout: float | None = None, *, blocking: bool | None = None)
| 66 | |
| 67 | @asynccontextmanager |
| 68 | async def read_lock(self, timeout: float | None = None, *, blocking: bool | None = None) -> AsyncGenerator[None]: |
| 69 | """ |
| 70 | Hold the lock until the context exits. See :meth:`acquire_read` for acquisition errors. |
| 71 | |
| 72 | :param timeout: seconds to wait, or ``None`` for the instance default |
| 73 | :param blocking: wait on contention, or ``None`` for the instance default |
| 74 | :yields: while the lock is held |
| 75 | """ |
| 76 | await self.acquire_read(timeout, blocking=blocking) |
| 77 | body_error: BaseException | None = None |
| 78 | try: |
| 79 | yield |
| 80 | except BaseException as error: |
| 81 | body_error = error |
| 82 | raise |
| 83 | finally: |
| 84 | await self._release_in_context(body_error) |
| 85 | |
| 86 | async def acquire_read( |
| 87 | self, timeout: float | None = None, *, blocking: bool | None = None |