Hi, On Tue, Jun 15, 2010 at 7:09 PM, coltsith <[email protected]> wrote:
> Hi Nick, thanks for responding. > > I understand. I think in that case I'll show an error like "This game > has been filled already, try refreshing" to user B. > I would suggest simply telling them that the game has been filled, then automatically refreshing - or at least removing the filled game - for them when they click okay. > However I'd still like to lock part of my code, just to avoid race > conditions and such. Could you point me in the right direction? Should > I be looking into locks or transactions when read/writing the game > list? > There's no reason to use locks - simply use the built in support for transactions. http://code.google.com/appengine/docs/python/datastore/transactions.html -Nick Johnson > > Thanks > > On Jun 15, 5:49 pm, "Nick Johnson (Google)" <[email protected]> > wrote: > > Hi, > > > > Locking won't help you here - consider the situation where user B fetches > > the list of games, and then user A 'takes' a game - say, half a second > > later, after user B's call completes, but before his browser finishes > > displaying it - you'll be left in the same situation. > > > > No matter how you handle things, there's always going to exist the > > possibility that immediately after you return a result set to user B, > > another user does something that makes that result set out of date. > > > > -Nick Johnson > > > > > > > > > > > > On Tue, Jun 15, 2010 at 3:48 PM, coltsith <[email protected]> wrote: > > > Hi, I'm writing a simple game server where players can create games > > > and browse games. I've come across the following dilemma though and > > > want to see if my solution is a good idea. The dilemma: > > > > > User A calls joinGameAndRemoveItFromList(). > > > > > User B calls fetchAvailableGamesInList() at the same time. > > > > > I'm concerned that User B may fetch the game that User A is joining > > > and removing from list (since it's no longer available) > > > > > My solution would be to lock the game list while User A is making his > > > call. That way User B would wait until User A is done with the list. > > > > > However, I realize that this could be very slow. Say there's thousands > > > of players all wanting to browse the available games (hey it could > > > happen!) and they shouldn't all have to wait for A to finish, > > > especially if A is slow for some reason. > > > > > Does anyone have any advice on if this is the right way to go, or if > > > there's a better solution? > > > > > Thanks! > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Google App Engine" group. > > > To post to this group, send email to [email protected] > . > > > To unsubscribe from this group, send email to > > > [email protected]<google-appengine%[email protected]><google-appengine%2Bunsubscrib > [email protected]> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/google-appengine?hl=en. > > > > -- > > Nick Johnson, Developer Programs Engineer, App Engine Google Ireland Ltd. > :: > > Registered in Dublin, Ireland, Registration Number: 368047 > > Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration > Number: > > 368047 > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-appengine%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-appengine?hl=en. > > -- Nick Johnson, Developer Programs Engineer, App Engine Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047 Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047 -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
