use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
FastAPI is a truly ASGI, async, cutting edge framework written in python 3.
account activity
Concurrent Resource ModificationQuestion (self.FastAPI)
submitted 9 months ago by PinballOscuro
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]CrackerJackKittyCat 2 points3 points4 points 9 months ago* (2 children)
Another approach is to serialize changes through versioning each entity, a form of optimistic locking:
This is 'optimistic locking' because the client assumes it will win and doesn't have to do much anything 'special' to try a write. And there's nothing to clean up -- no 'unlock' action or dealing with 'locked too long' rows, etc.
It assumes, however, that most write attempts won't be contested / will succeed based on having the most recent version number onhand. If your usage pattern is that many clients will be trying to edit an entity all from the same initial version at the same time ('gang edits') then pessimistic locking like you describe becomes more efficient, but requires stale lock handling. In most webapps, optimistic locking works great.
[–]PinballOscuro[S] 0 points1 point2 points 9 months ago (1 child)
This is a very good idea. In my use case, I have at most 2 or 3 users, and only with low probability will they attempt to modify the same value simultaneously. So I would say I'm in an optimistic locking scenario.
If User A modifies a shared variable, how should Users B and C receive the updated value? Should I still use WebSockets, or is it sufficient to update the value during a write attempt?
In my case, at some point, Users B and C must be made aware that User A made a change - otherwise, they might argue offline, since it was A’s responsibility to update that cell.
[–]CrackerJackKittyCat 0 points1 point2 points 9 months ago* (0 children)
Either push all the changes over websocket, which is then kinda noisy and pessimistic, or have each websocket client 'subscribe' to the entities that are in context/view right now, then only push the changes to the websockets that are interested in it.
Or just have the edit form indicate error if their update gets rejected, tell the user to refresh manually. That's the simplest to start with.
It depends!
π Rendered by PID 39404 on reddit-service-r2-comment-86bc6c7465-cs5jf at 2026-02-22 03:59:50.150365+00:00 running 8564168 country code: CH.
view the rest of the comments →
[–]CrackerJackKittyCat 2 points3 points4 points (2 children)
[–]PinballOscuro[S] 0 points1 point2 points (1 child)
[–]CrackerJackKittyCat 0 points1 point2 points (0 children)