MCPcopy
hub / github.com/psycopg/psycopg / pipeline

Method pipeline

psycopg/psycopg/connection.py:437–453  ·  view source on GitHub ↗

Context manager to switch the connection into pipeline mode.

(self)

Source from the content-addressed store, hash-verified

435
436 @contextmanager
437 def pipeline(self) -> Iterator[Pipeline]:
438 """Context manager to switch the connection into pipeline mode."""
439 with self.lock:
440 self._check_connection_ok()
441
442 if (pipeline := self._pipeline) is None:
443 # WARNING: reference loop, broken ahead.
444 pipeline = self._pipeline = Pipeline(self)
445
446 try:
447 with pipeline:
448 yield pipeline
449 finally:
450 if pipeline.level == 0:
451 with self.lock:
452 assert pipeline is self._pipeline
453 self._pipeline = None
454
455 @contextmanager
456 def _pipeline_nolock(self) -> Iterator[Pipeline]:

Callers 15

transactionMethod · 0.95
pipelineFunction · 0.45
apipelineFunction · 0.45
test_pipeline_statusFunction · 0.45
test_reprFunction · 0.45
test_connection_closedFunction · 0.45
test_pipeline_statusFunction · 0.45
test_pipeline_reenterFunction · 0.45

Calls 2

PipelineClass · 0.85
_check_connection_okMethod · 0.80

Tested by 15

test_pipeline_statusFunction · 0.36
test_reprFunction · 0.36
test_connection_closedFunction · 0.36
test_pipeline_statusFunction · 0.36
test_pipeline_reenterFunction · 0.36
test_cursor_streamFunction · 0.36
test_server_cursorFunction · 0.36