MCPcopy
hub / github.com/psycopg/psycopg / _enter_gen

Method _enter_gen

psycopg/psycopg/_pipeline_base.py:65–77  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

63 return capabilities.has_pipeline()
64
65 def _enter_gen(self) -> PQGen[None]:
66 capabilities.has_pipeline(check=True)
67 if self.level == 0:
68 self.pgconn.enter_pipeline_mode()
69 elif self.command_queue or self.pgconn.transaction_status == ACTIVE:
70 # Nested pipeline case.
71 # Transaction might be ACTIVE when the pipeline uses an "implicit
72 # transaction", typically in autocommit mode. But when entering a
73 # Psycopg transaction(), we expect the IDLE state. By sync()-ing,
74 # we make sure all previous commands are completed and the
75 # transaction gets back to IDLE.
76 yield from self._sync_gen()
77 self.level += 1
78
79 def _exit(self, exc: BaseException | None) -> None:
80 self.level -= 1

Callers 2

__enter__Method · 0.45
__aenter__Method · 0.45

Calls 3

_sync_genMethod · 0.95
has_pipelineMethod · 0.80
enter_pipeline_modeMethod · 0.45

Tested by

no test coverage detected