mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-21 07:26:18 -05:00
Channel and map subscription changes wait for a concurrent writer
PUT/DELETE /api/videos/channels/<id>, POST /api/videos/channels/<id>/tag,
and POST/DELETE /api/map/subscribe read, then wrote, in the request's
deferred transaction, so they failed with a 500 ("database is locked")
when another connection wrote in between. They now write inside
request.ctx.db.write().
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
22afb81879
commit
8022b4f86b
4 changed files with 76 additions and 9 deletions
|
|
@ -48,7 +48,8 @@ def get_subscriptions(request: Request):
|
|||
@wrol_mode_check
|
||||
async def post_subscribe(request: Request, body: schema.MapSubscribeRequest):
|
||||
try:
|
||||
await lib.subscribe(request.ctx.session, body.name, body.region)
|
||||
with request.ctx.db.write() as session:
|
||||
await lib.subscribe(session, body.name, body.region)
|
||||
except ValueError as e:
|
||||
return response.json({'error': str(e)}, HTTPStatus.BAD_REQUEST)
|
||||
|
||||
|
|
@ -61,7 +62,8 @@ async def post_subscribe(request: Request, body: schema.MapSubscribeRequest):
|
|||
@wrol_mode_check
|
||||
async def delete_subscription(request: Request, region: str):
|
||||
try:
|
||||
await lib.unsubscribe(request.ctx.session, region)
|
||||
with request.ctx.db.write() as session:
|
||||
await lib.unsubscribe(session, region)
|
||||
except ValueError as e:
|
||||
return response.json({'error': str(e)}, HTTPStatus.NOT_FOUND)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue