| 121 | self._source_traceback = None |
| 122 | |
| 123 | def __del__(self): |
| 124 | if not self.is_closed() and self._protocol is not None: |
| 125 | if self._source_traceback: |
| 126 | msg = "unclosed connection {!r}; created at:\n {}".format( |
| 127 | self, self._source_traceback) |
| 128 | else: |
| 129 | msg = ( |
| 130 | "unclosed connection {!r}; run in asyncio debug " |
| 131 | "mode to show the traceback of connection " |
| 132 | "origin".format(self) |
| 133 | ) |
| 134 | |
| 135 | warnings.warn(msg, ResourceWarning) |
| 136 | if not self._loop.is_closed(): |
| 137 | self.terminate() |
| 138 | |
| 139 | async def add_listener(self, channel, callback): |
| 140 | """Add a listener for Postgres notifications. |