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

Method __del__

asyncpg/connection.py:125–143  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

123 self._source_traceback = None
124
125 def __del__(self):
126 if not self.is_closed() and self._protocol is not None:
127 if self._source_traceback:
128 msg = "unclosed connection {!r}; created at:\n {}".format(
129 self, self._source_traceback)
130 else:
131 msg = (
132 "unclosed connection {!r}; run in asyncio debug "
133 "mode to show the traceback of connection "
134 "origin".format(self)
135 )
136
137 warnings.warn(msg, ResourceWarning)
138 if not self._loop.is_closed():
139 # A weak holder reference may still be live during GC.
140 # Finalization must not notify the pool and restart
141 # maintenance.
142 self._pool_holder = None
143 self.terminate()
144
145 async def add_listener(self, channel, callback):
146 """Add a listener for Postgres notifications.

Callers

nothing calls this directly

Calls 2

is_closedMethod · 0.95
terminateMethod · 0.95

Tested by

no test coverage detected