MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _soft_close

Method _soft_close

lib/sqlalchemy/engine/cursor.py:1755–1790  ·  view source on GitHub ↗

Soft close this :class:`_engine.CursorResult`. This releases all DBAPI cursor resources, but leaves the CursorResult "open" from a semantic perspective, meaning the fetchXXX() methods will continue to return empty results. This method is called automatically when:

(self, hard: bool = False)

Source from the content-addressed store, hash-verified

1753 return metadata
1754
1755 def _soft_close(self, hard: bool = False) -> None:
1756 """Soft close this :class:`_engine.CursorResult`.
1757
1758 This releases all DBAPI cursor resources, but leaves the
1759 CursorResult "open" from a semantic perspective, meaning the
1760 fetchXXX() methods will continue to return empty results.
1761
1762 This method is called automatically when:
1763
1764 * all result rows are exhausted using the fetchXXX() methods.
1765 * cursor.description is None.
1766
1767 This method is **not public**, but is documented in order to clarify
1768 the "autoclose" process used.
1769
1770 .. seealso::
1771
1772 :meth:`_engine.CursorResult.close`
1773
1774
1775 """
1776
1777 if (not hard and self._soft_closed) or (hard and self.closed):
1778 return
1779
1780 if hard:
1781 self.closed = True
1782 self.cursor_strategy.hard_close(self, self.cursor)
1783 else:
1784 self.cursor_strategy.soft_close(self, self.cursor)
1785
1786 if not self._soft_closed:
1787 cursor = self.cursor
1788 self.cursor = None # type: ignore
1789 self.connection._safe_close_cursor(cursor)
1790 self._soft_closed = True
1791
1792 @property
1793 def inserted_primary_key_rows(self) -> List[Optional[Any]]:

Callers 11

closeMethod · 0.95
fetchoneMethod · 0.45
fetchmanyMethod · 0.45
fetchallMethod · 0.45
fetchoneMethod · 0.45
fetchmanyMethod · 0.45
fetchallMethod · 0.45
fetchoneMethod · 0.45
fetchmanyMethod · 0.45
fetchallMethod · 0.45

Calls 3

hard_closeMethod · 0.45
soft_closeMethod · 0.45
_safe_close_cursorMethod · 0.45

Tested by

no test coverage detected