**INTERNAL** Drive a single synchronous streaming iteration for ``req`` and apply uniform teardown/error handling. Shared by the blocking (``couchbase``) and Twisted (``txcouchbase``) row iterators.
(req)
| 76 | |
| 77 | |
| 78 | def stream_next(req): |
| 79 | """ |
| 80 | **INTERNAL** |
| 81 | |
| 82 | Drive a single synchronous streaming iteration for ``req`` and apply uniform teardown/error |
| 83 | handling. Shared by the blocking (``couchbase``) and Twisted (``txcouchbase``) row iterators. |
| 84 | """ |
| 85 | try: |
| 86 | row = req._get_next_row() |
| 87 | # See stream_anext for why the span is ended here (idempotent, ends on the first row). |
| 88 | req._process_core_span() |
| 89 | return row |
| 90 | except StopIteration: |
| 91 | req._done_streaming = True |
| 92 | req._process_core_span() |
| 93 | req._get_metadata() |
| 94 | raise |
| 95 | except CouchbaseException as ex: |
| 96 | req._process_core_span(exc_val=ex) |
| 97 | raise |
| 98 | except Exception as ex: |
| 99 | excptn = _internal_exception(str(ex)) |
| 100 | req._process_core_span(exc_val=excptn) |
| 101 | raise excptn |
| 102 | except BaseException as ex: |
| 103 | # KeyboardInterrupt / SystemExit -- see module note above. |
| 104 | req._process_core_span(exc_val=ex) |
| 105 | raise |