Start a context block with a new transaction or nested transaction. :param savepoint_name: Name of the savepoint used to manage a nested transaction. If `!None`, one will be chosen automatically. :param force_rollback: Roll back the transaction at the end of the
(
self, savepoint_name: str | None = None, force_rollback: bool = False
)
| 343 | |
| 344 | @contextmanager |
| 345 | def transaction( |
| 346 | self, savepoint_name: str | None = None, force_rollback: bool = False |
| 347 | ) -> Iterator[Transaction]: |
| 348 | class="st">""" |
| 349 | Start a context block with a new transaction or nested transaction. |
| 350 | |
| 351 | :param savepoint_name: Name of the savepoint used to manage a nested |
| 352 | transaction. If `!None`, one will be chosen automatically. |
| 353 | :param force_rollback: Roll back the transaction at the end of the |
| 354 | block even if there were no error (e.g. to try a no-op process). |
| 355 | :rtype: Transaction |
| 356 | class="st">""" |
| 357 | tx = Transaction(self, savepoint_name, force_rollback) |
| 358 | if self._pipeline: |
| 359 | with self.pipeline(), tx, self.pipeline(): |
| 360 | yield tx |
| 361 | else: |
| 362 | with tx: |
| 363 | yield tx |
| 364 | |
| 365 | def notifies( |
| 366 | self, *, timeout: float | None = None, stop_after: int | None = None |