(result: _RT, calling_method: Any)
| 963 | |
| 964 | |
| 965 | async 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 |
no test coverage detected