MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / _maybe_gc_stmt

Method _maybe_gc_stmt

asyncpg/connection.py:1648–1665  ·  view source on GitHub ↗
(self, stmt)

Source from the content-addressed store, hash-verified

1646 self._stmts_to_close.clear()
1647
1648 def _maybe_gc_stmt(self, stmt):
1649 if (
1650 stmt.refs == 0
1651 and stmt.name
1652 and not self._stmt_cache.has(
1653 (stmt.query, stmt.record_class, stmt.ignore_custom_codec)
1654 )
1655 ):
1656 # If low-level `stmt` isn't referenced from any high-level
1657 # `PreparedStatement` object and is not in the `_stmt_cache`:
1658 #
1659 # * mark it as closed, which will make it non-usable
1660 # for any `PreparedStatement` or for methods like
1661 # `Connection.fetch()`.
1662 #
1663 # * schedule it to be formally closed on the server.
1664 stmt.mark_closed()
1665 self._stmts_to_close.add(stmt)
1666
1667 async def _cleanup_stmts(self):
1668 # Called whenever we create a new prepared statement in

Callers 4

_weak_maybe_gc_stmtFunction · 0.80
__del__Method · 0.80
__del__Method · 0.80
__del__Method · 0.80

Calls 1

hasMethod · 0.80

Tested by

no test coverage detected