Read -> change -> save. Thread safe.
- by Pavel Alexeev
This code should automatically connect players when they enter a game.
But the problem is when two users try to connect at the same time - in this case 2nd user can easily overwrite changes made by 1st user ('room_1' variable).
How could I make it thread safe?
def join(userId):
users = memcache.get('room_1')
users.append(userId)
memcache.set('room_1', users)
return users
I'm using Google App Engine (python) and going to implement simple game-server for exchanging peers given by Adobe Stratus.