Context: I am developing a web application using webapp2
web-framework with python to be hosted on GAE.
The web application (web-app from now on), is a chess variant. Being a first timer, I have definitely made a lot of design blunders. One of them, is what this question is regarding to, I will come to it in a short while.
The aim of the web-app was to allow quite a large number of players to play 2-player chess, such that multiple games are running in parallel. While not exceeding the free quota on GAE. (I am a student).
To do that, I thought that I would create a new game object, and store its id(game_object)
along with the machine_id
of the two players playing on that instance, in the datastore.
When querying the datastore with the machine_id
of a player, I could get a id()
value, and I thought could use that value as a key
in a dictionary wherein a reference to the game_object
forms the value.
Doing this, doesn't need me to write/update the datastore, hence saving on the precious writes. I could easily modify the game-state of the game_object
, and it could be still referenced by the id()
.
But, now what happens is, this works fine for a few moves. After that the garbage collection takes place and the game_object
is wiped off the memory. Raising a NameError exception.
My question is, can this be solved by creating new game_objects in a separate module where garbage collection is turned off, and then periodically/event-triggered freeing the memory? If not? How do I come around this problem?