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

Method _deactivate_inactive_connection

asyncpg/pool.py:326–341  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

324 self._inactive_callback = None
325
326 def _deactivate_inactive_connection(self) -> None:
327 if self._in_use is not None:
328 raise exceptions.InternalClientError(
329 'attempting to deactivate an acquired connection')
330
331 self._inactive_callback = None
332 if self._con is not None:
333 if (self.is_connected() and not self._pool.is_closing() and
334 self._pool.get_size() <= self._pool.get_min_size()):
335 # A floor connection needs no further inactivity checks.
336 # Acquiring and releasing it will arm a new timer.
337 return
338
339 # The connection is idle and not in use, so it's fine to
340 # use terminate() instead of close().
341 self._con.terminate()
342
343 def _release_on_close(self) -> None:
344 self._maybe_cancel_inactive_callback()

Callers

nothing calls this directly

Calls 5

is_connectedMethod · 0.95
is_closingMethod · 0.80
get_sizeMethod · 0.80
get_min_sizeMethod · 0.80
terminateMethod · 0.45

Tested by

no test coverage detected