MCPcopy Create free account
hub / github.com/couchbase/couchbase-python-client / stream_anext

Function stream_anext

couchbase/logic/streaming.py:45–75  ·  view source on GitHub ↗

**INTERNAL** Drive a single async streaming iteration for ``req`` and apply uniform teardown/error handling.

(req)

Source from the content-addressed store, hash-verified

43
44
45async def stream_anext(req):
46 """
47 **INTERNAL**
48
49 Drive a single async streaming iteration for ``req`` and apply uniform teardown/error handling.
50 """
51 try:
52 # this is a blocking operation, so it is offloaded to the request's executor
53 row = await req._loop.run_in_executor(req._tp_executor, req._get_next_row)
54 # We want to end the streaming op span once we have a response from the C++ core.
55 # Unfortunately right now, that means we need to wait until we have the first row (or we
56 # have an error). As this is idempotent, it is safe to call for each row (it will only do
57 # work for the first call).
58 req._process_core_span()
59 return row
60 except StopAsyncIteration:
61 req._done_streaming = True
62 req._finalize()
63 req._get_metadata()
64 raise
65 except CouchbaseException as ex:
66 req._finalize(exc_val=ex)
67 raise
68 except Exception as ex:
69 excptn = _internal_exception(str(ex))
70 req._finalize(exc_val=excptn)
71 raise excptn
72 except BaseException as ex:
73 # asyncio.CancelledError / KeyboardInterrupt / SystemExit -- see module note above.
74 req._finalize(exc_val=ex)
75 raise
76
77
78def stream_next(req):

Calls 4

_internal_exceptionFunction · 0.85
_process_core_spanMethod · 0.45
_finalizeMethod · 0.45
_get_metadataMethod · 0.45