yield from self._communicate_gen()
def _exit_gen(self) -> PQGen[None]:
+ """Exit current pipeline by sending a Sync and, unless within a nested
+ pipeline, also fetch back all remaining results.
+ """
try:
- # Send any pending commands (e.g. COMMIT or Sync);
- # while processing results, we might get errors...
yield from self._sync_gen()
finally:
- # then fetch all remaining results but without forcing
- # flush since we emitted a sync just before.
- yield from self._fetch_gen(flush=False)
+ if self.level == 1:
+ # No need to force flush since we emitted a sync just before.
+ yield from self._fetch_gen(flush=False)
def _communicate_gen(self) -> PQGen[None]:
"""Communicate with pipeline to send commands and possibly fetch