MCPcopy Index your code
hub / github.com/MagicStack/asyncpg / reset

Method reset

asyncpg/connection.py:1544–1571  ·  view source on GitHub ↗

Reset the connection state. Calling this will reset the connection session state to a state resembling that of a newly obtained connection. Namely, an open transaction (if any) is rolled back, open cursors are closed, all `LISTEN <https://www.postgresql.org/docs/cur

(self, *, timeout=None)

Source from the content-addressed store, hash-verified

1542 await self.execute("ROLLBACK")
1543
1544 async def reset(self, *, timeout=None):
1545 """Reset the connection state.
1546
1547 Calling this will reset the connection session state to a state
1548 resembling that of a newly obtained connection. Namely, an open
1549 transaction (if any) is rolled back, open cursors are closed,
1550 all `LISTEN <https://www.postgresql.org/docs/current/sql-listen.html>`_
1551 registrations are removed, all session configuration
1552 variables are reset to their default values, and all advisory locks
1553 are released.
1554
1555 Note that the above describes the default query returned by
1556 :meth:`Connection.get_reset_query`. If one overloads the method
1557 by subclassing ``Connection``, then this method will do whatever
1558 the overloaded method returns, except open transactions are always
1559 terminated and any callbacks registered by
1560 :meth:`Connection.add_listener` or :meth:`Connection.add_log_listener`
1561 are removed.
1562
1563 :param float timeout:
1564 A timeout for resetting the connection. If not specified, defaults
1565 to no timeout.
1566 """
1567 async with compat.timeout(timeout):
1568 await self._reset()
1569 reset_query = self.get_reset_query()
1570 if reset_query:
1571 await self.execute(reset_query)
1572
1573 def _abort(self):
1574 # Put the connection into the aborted state.

Callers 1

releaseMethod · 0.45

Calls 3

_resetMethod · 0.95
get_reset_queryMethod · 0.95
executeMethod · 0.95

Tested by

no test coverage detected