MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _ensure_sync_result

Function _ensure_sync_result

lib/sqlalchemy/ext/asyncio/result.py:965–994  ·  view source on GitHub ↗
(result: _RT, calling_method: Any)

Source from the content-addressed store, hash-verified

963
964
965async def _ensure_sync_result(result: _RT, calling_method: Any) -> _RT:
966 cursor_result: CursorResult[Any]
967
968 try:
969 is_cursor = result._is_cursor
970 except AttributeError:
971 # legacy execute(DefaultGenerator) case
972 return result
973
974 if not is_cursor:
975 cursor_result = getattr(result, "raw", None) # type: ignore
976 else:
977 cursor_result = result # type: ignore
978 if cursor_result and cursor_result.context._is_server_side:
979 await greenlet_spawn(cursor_result.close)
980 raise async_exc.AsyncMethodRequired(
981 "Can't use the %s.%s() method with a "
982 "server-side cursor. "
983 "Use the %s.stream() method for an async "
984 "streaming result set."
985 % (
986 calling_method.__self__.__class__.__name__,
987 calling_method.__name__,
988 calling_method.__self__.__class__.__name__,
989 )
990 )
991
992 if is_cursor and cursor_result.cursor is not None:
993 await cursor_result.cursor._async_soft_close()
994 return result

Callers 3

executeMethod · 0.85
exec_driver_sqlMethod · 0.85
executeMethod · 0.85

Calls 2

greenlet_spawnFunction · 0.85
_async_soft_closeMethod · 0.80

Tested by

no test coverage detected