MCPcopy
hub / github.com/MagicStack/asyncpg / _maybe_gc_stmt

Method _maybe_gc_stmt

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

Source from the content-addressed store, hash-verified

1620 self._stmts_to_close.clear()
1621
1622 def _maybe_gc_stmt(self, stmt):
1623 if (
1624 stmt.refs == 0
1625 and stmt.name
1626 and not self._stmt_cache.has(
1627 (stmt.query, stmt.record_class, stmt.ignore_custom_codec)
1628 )
1629 ):
1630 # If low-level `stmt` isn't referenced from any high-level
1631 # `PreparedStatement` object and is not in the `_stmt_cache`:
1632 #
1633 # * mark it as closed, which will make it non-usable
1634 # for any `PreparedStatement` or for methods like
1635 # `Connection.fetch()`.
1636 #
1637 # * schedule it to be formally closed on the server.
1638 stmt.mark_closed()
1639 self._stmts_to_close.add(stmt)
1640
1641 async def _cleanup_stmts(self):
1642 # 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