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

Method close

asyncpg/connection.py:1502–1519  ·  view source on GitHub ↗

Close the connection gracefully. :param float timeout: Optional timeout value in seconds. .. versionchanged:: 0.14.0 Added the *timeout* parameter.

(self, *, timeout=None)

Source from the content-addressed store, hash-verified

1500 return self._aborted or not self._protocol.is_connected()
1501
1502 async def close(self, *, timeout=None):
1503 """Close the connection gracefully.
1504
1505 :param float timeout:
1506 Optional timeout value in seconds.
1507
1508 .. versionchanged:: 0.14.0
1509 Added the *timeout* parameter.
1510 """
1511 try:
1512 if not self.is_closed():
1513 await self._protocol.close(timeout)
1514 except (Exception, asyncio.CancelledError):
1515 # If we fail to close gracefully, abort the connection.
1516 self._abort()
1517 raise
1518 finally:
1519 self._cleanup()
1520
1521 def terminate(self):
1522 """Terminate the connection without waiting for pending data."""

Callers 1

_copy_outMethod · 0.45

Calls 3

is_closedMethod · 0.95
_abortMethod · 0.95
_cleanupMethod · 0.95

Tested by

no test coverage detected