Read -> change -> save. Thread safe.
Posted
by Pavel Alexeev
on Stack Overflow
See other posts from Stack Overflow
or by Pavel Alexeev
Published on 2010-06-07T06:18:34Z
Indexed on
2010/06/07
6:22 UTC
Read the original article
Hit count: 232
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.
© Stack Overflow or respective owner