(self)
| 1287 | (SessionTransactionState.ACTIVE,), SessionTransactionState.PREPARED |
| 1288 | ) |
| 1289 | def _prepare_impl(self) -> None: |
| 1290 | if self._parent is None or self.nested: |
| 1291 | self.session.dispatch.before_commit(self.session) |
| 1292 | |
| 1293 | stx = self.session._transaction |
| 1294 | assert stx is not None |
| 1295 | if stx is not self: |
| 1296 | for subtransaction in stx._iterate_self_and_parents(upto=self): |
| 1297 | subtransaction.commit() |
| 1298 | |
| 1299 | if not self.session._flushing: |
| 1300 | for _flush_guard in range(100): |
| 1301 | if self.session._is_clean(): |
| 1302 | break |
| 1303 | self.session.flush() |
| 1304 | else: |
| 1305 | raise exc.FlushError( |
| 1306 | "Over 100 subsequent flushes have occurred within " |
| 1307 | "session.commit() - is an after_flush() hook " |
| 1308 | "creating new objects?" |
| 1309 | ) |
| 1310 | |
| 1311 | if self._parent is None and self.session.twophase: |
| 1312 | try: |
| 1313 | for t in set(self._connections.values()): |
| 1314 | cast("TwoPhaseTransaction", t[1]).prepare() |
| 1315 | except: |
| 1316 | with util.safe_reraise(): |
| 1317 | with self._expect_state(SessionTransactionState.CLOSED): |
| 1318 | self.rollback() |
| 1319 | |
| 1320 | self._state = SessionTransactionState.PREPARED |
| 1321 | |
| 1322 | @_StateChange.declare_states( |
| 1323 | (SessionTransactionState.ACTIVE, SessionTransactionState.PREPARED), |
no test coverage detected