Release the lock (if held) and close the underlying SQLite connection. After calling this method, the lock instance is no longer usable.
(self)
| 221 | await self._run(self._lock.release, force=force) |
| 222 | |
| 223 | async def close(self) -> None: |
| 224 | """ |
| 225 | Release the lock (if held) and close the underlying SQLite connection. |
| 226 | |
| 227 | After calling this method, the lock instance is no longer usable. |
| 228 | |
| 229 | """ |
| 230 | _ensure_current_process() |
| 231 | if self._inherited: # pragma: needs fork |
| 232 | return |
| 233 | if self._closed: |
| 234 | return |
| 235 | close_future = self._submit(self._lock.close) |
| 236 | try: |
| 237 | await _wait_until_done(close_future) |
| 238 | except asyncio.CancelledError as cancellation: |
| 239 | try: |
| 240 | await _drain_future(close_future) |
| 241 | except BaseException as error: # ruff:ignore[blind-except] # reported with the cancellation below |
| 242 | _raise_cancelled_error(cancellation, error) |
| 243 | self._closed = True |
| 244 | self._shutdown_owned_executor() |
| 245 | raise |
| 246 | _future_result(close_future) |
| 247 | self._closed = True |
| 248 | # Wait for the worker to exit rather than letting it drain in the background: a caller that forks right |
| 249 | # after closing deserves a single-threaded process, and os.fork warns about any surviving thread. |
| 250 | if self._owns_executor: |
| 251 | await asyncio.to_thread(functools.partial(self._executor.shutdown, wait=True)) |
| 252 | |
| 253 | async def _run_acquire(self, acquire: Callable[[], AcquireReturnProxy]) -> None: |
| 254 | acquire_future = self._submit(acquire) |