MCPcopy
hub / github.com/psycopg/psycopg / wait

Method wait

psycopg/psycopg/connection.py:476–494  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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)

Callers 15

commitMethod · 0.95
rollbackMethod · 0.95
notifiesMethod · 0.95
set_autocommitMethod · 0.95
set_isolation_levelMethod · 0.95
set_read_onlyMethod · 0.95
set_deferrableMethod · 0.95
tpc_beginMethod · 0.95
tpc_prepareMethod · 0.95
tpc_commitMethod · 0.95
tpc_rollbackMethod · 0.95
test_notify_query_notifyFunction · 0.45

Calls 1

_try_cancelMethod · 0.95

Tested by 15

test_notify_query_notifyFunction · 0.36
copy_taskFunction · 0.36
test_copy_concurrencyFunction · 0.36
test_notify_query_notifyFunction · 0.36
writerFunction · 0.36
unblockerFunction · 0.36
test_wait_r_nowaitFunction · 0.36
copy_taskFunction · 0.36
test_copy_concurrencyFunction · 0.36
test_ctrl_cFunction · 0.36
workerFunction · 0.36