(self)
| 1693 | return self |
| 1694 | |
| 1695 | async def reset(self): |
| 1696 | self.command_stack = [] |
| 1697 | self.scripts = set() |
| 1698 | try: |
| 1699 | # make sure to reset the connection state in the event that we were |
| 1700 | # watching something |
| 1701 | if self.watching and self.connection: |
| 1702 | try: |
| 1703 | # call this manually since our unwatch or |
| 1704 | # immediate_execute_command methods can call reset() |
| 1705 | await self.connection.send_command("UNWATCH") |
| 1706 | await self.connection.read_response() |
| 1707 | except ConnectionError: |
| 1708 | # disconnect will also remove any previous WATCHes |
| 1709 | if self.connection: |
| 1710 | await self.connection.disconnect() |
| 1711 | except asyncio.CancelledError: |
| 1712 | # Disconnect so any unread UNWATCH reply does not get |
| 1713 | # served to the next caller that takes the connection. |
| 1714 | if self.connection: |
| 1715 | await self.connection.disconnect() |
| 1716 | raise |
| 1717 | finally: |
| 1718 | self.watching = False |
| 1719 | self.explicit_transaction = False |
| 1720 | # We can safely return the connection to the pool here since we're |
| 1721 | # sure we're no longer WATCHing anything. Detach self.connection |
| 1722 | # before awaiting release: if a second cancel aborts the await, |
| 1723 | # the pipeline must not be left holding a reference to a |
| 1724 | # connection that is being returned to the pool. Shield the |
| 1725 | # release itself so a second cancel cannot split the pool's |
| 1726 | # internal in-use/available bookkeeping mid-update. |
| 1727 | if self.connection: |
| 1728 | connection, self.connection = self.connection, None |
| 1729 | await asyncio.shield(self.connection_pool.release(connection)) |
| 1730 | |
| 1731 | async def aclose(self) -> None: |
| 1732 | """Alias for reset(), a standard method name for cleanup""" |
no test coverage detected