Hold the lock until the context exits. See :meth:`acquire_write` 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)
| 134 | |
| 135 | @asynccontextmanager |
| 136 | async def write_lock(self, timeout: float | None = None, *, blocking: bool | None = None) -> AsyncGenerator[None]: |
| 137 | """ |
| 138 | Hold the lock until the context exits. See :meth:`acquire_write` for acquisition errors. |
| 139 | |
| 140 | :param timeout: seconds to wait, or ``None`` for the instance default |
| 141 | :param blocking: wait on contention, or ``None`` for the instance default |
| 142 | :yields: while the lock is held |
| 143 | """ |
| 144 | await self.acquire_write(timeout, blocking=blocking) |
| 145 | body_error: BaseException | None = None |
| 146 | try: |
| 147 | yield |
| 148 | except BaseException as error: |
| 149 | body_error = error |
| 150 | raise |
| 151 | finally: |
| 152 | await self._release_in_context(body_error) |
| 153 | |
| 154 | async def acquire_write( |
| 155 | self, timeout: float | None = None, *, blocking: bool | None = None |