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