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

Method close

asyncpg/connection.py:1525–1542  ·  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

1523 return self._aborted or not self._protocol.is_connected()
1524
1525 async def close(self, *, timeout=None):
1526 """Close the connection gracefully.
1527
1528 :param float timeout:
1529 Optional timeout value in seconds.
1530
1531 .. versionchanged:: 0.14.0
1532 Added the *timeout* parameter.
1533 """
1534 try:
1535 if not self.is_closed():
1536 await self._protocol.close(timeout)
1537 except (Exception, asyncio.CancelledError):
1538 # If we fail to close gracefully, abort the connection.
1539 self._abort()
1540 raise
1541 finally:
1542 self._cleanup()
1543
1544 def terminate(self):
1545 """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