Skip to content

Commit 4408a73

Browse files
committed
select for update is one approach [with_for_update]
1 parent f59e9f7 commit 4408a73

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/allocation/adapters/repository.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,9 @@ def add(self, product):
2020
self.session.add(product)
2121

2222
def get(self, sku):
23-
print(sku, type(sku))
24-
return self.session.query(model.Product).filter_by(sku=sku).first()
23+
return (
24+
self.session.query(model.Product)
25+
.filter_by(sku=sku)
26+
.with_for_update()
27+
.first()
28+
)

0 commit comments

Comments
 (0)