Skip to content

Commit 6571c4d

Browse files
committed
alternative: isolation=SERIALIZABLE [chapter_06_aggregate_ends]
1 parent 6e18fd1 commit 6571c4d

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/allocation/adapters/repository.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,4 @@ def add(self, product):
2222
self.session.add(product)
2323

2424
def get(self, sku):
25-
return self.session.query(model.Product) \
26-
.filter_by(sku=sku) \
27-
.with_for_update() \
28-
.first()
25+
return self.session.query(model.Product).filter_by(sku=sku).first()

src/allocation/service_layer/unit_of_work.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def rollback(self):
3030

3131
DEFAULT_SESSION_FACTORY = sessionmaker(bind=create_engine(
3232
config.get_postgres_uri(),
33+
isolation_level="SERIALIZABLE",
3334
))
3435

3536
class SqlAlchemyUnitOfWork(AbstractUnitOfWork):

0 commit comments

Comments
 (0)