Close the state manager, flushing any pending writes to disk.
(self)
| 374 | await self.set_state(token, state, **context) |
| 375 | |
| 376 | async def close(self): |
| 377 | """Close the state manager, flushing any pending writes to disk.""" |
| 378 | async with self._state_manager_lock: |
| 379 | if self._write_queue_task: |
| 380 | self._write_queue_task.cancel() |
| 381 | with contextlib.suppress(asyncio.CancelledError): |
| 382 | await self._write_queue_task |
| 383 | self._write_queue_task = None |
| 384 | # Dump unlocked locks. |
| 385 | for token, lock in tuple(self._states_locks.items()): |
| 386 | if not lock.locked(): |
| 387 | self._states_locks.pop(token) |