Consume a generator operating on the connection. The function must be used on generators that don't change connection fd (i.e. not on connect and reset).
(self, gen: PQGen[RV], interval: float = _WAIT_INTERVAL)
| 474 | self._pipeline = None |
| 475 | |
| 476 | def wait(self, gen: PQGen[RV], interval: float = _WAIT_INTERVAL) -> RV: |
| 477 | """ |
| 478 | Consume a generator operating on the connection. |
| 479 | |
| 480 | The function must be used on generators that don't change connection |
| 481 | fd (i.e. not on connect and reset). |
| 482 | """ |
| 483 | try: |
| 484 | return waiting.wait(gen, self.pgconn.socket, interval=interval) |
| 485 | except _INTERRUPTED: |
| 486 | if self.pgconn.transaction_status == ACTIVE: |
| 487 | # On Ctrl-C, try to cancel the query in the server, otherwise |
| 488 | # the connection will remain stuck in ACTIVE state. |
| 489 | self._try_cancel(timeout=5.0) |
| 490 | try: |
| 491 | waiting.wait(gen, self.pgconn.socket, interval=interval) |
| 492 | except e.QueryCanceled: |
| 493 | pass # as expected |
| 494 | raise |
| 495 | |
| 496 | def _set_autocommit(self, value: bool) -> None: |
| 497 | self.set_autocommit(value) |