I've been working on this particular snag for a couple of months and
I'd love to get some help from the experts and googlers here.  I have
an app ("gas") that has to check periodically for idle users who are
identified by an old ping time.  These users are then marked as
inactive by setting their room field to None.  There are a few hundred
entries in the player datamodel but never more than 10 total users who
are in the current room.  The function only works on one room at a
time to keep it from selecting too many players and taking too long.
It never has to loop over more than 1 or 2 players in a single
execution to mark them.

  However, it appears that getting the first player from this database
query sometimes takes several seconds and ends in either a timeout
error ("Timeout") or sometimes an internal error ("InternalError:
internal error").

  This timeout or hang never shows up in local testing (only on the
production server).  There are many times where this function works
exactly as expected without errors or hangs, and then other times
where I'll get the timeout on nearly every execution (sometimes many
errors per minute if several people are playing).  Due to the nature
of the game, several players are playing at the same time and connect
regularly to the server so perhaps there is some contention going on
between the multiple threads (although only one player at a time ever
tries to execute this function.)

  So, my questions are:  Am I forming my query badly or doing
something else obviously wrong?  Or, is there perhaps a datamodel bug
or performance issue that I'm consistently tickling?

  Thanks in advance for any help.  I've included the relevant code
snippets below along with a sample debug output and I'm happy to
provide any other information you might find useful.

Rob
http://www.guessasketch.com/


------ Datamodel Snippet -------

class PlayerDb(db.Model):
    id = db.StringProperty()  # id based on the google db key
    name = db.StringProperty() # username (unique)
    room = db.ReferenceProperty() # what room the player is in
    lastPing = db.FloatProperty() # stored in float seconds from the
epoch for simplicity

    ...

------ Code Snippet ------

        logging.debug("Starting pruneInactive\n")

        # first, grab all the players who's ping is older than 10
seconds in our room
        query = datamodel.PlayerDb2.all()
        query.filter("room =", self.db.room)
        query.filter("lastPing <", time.time() - TIMEOUT_TIME)

        logging.debug("Query is built\n")

        playerList = []
        found = 0

        logging.debug("Ready to start first prune\n")

        for curplayer in query:            # THIS IS THE LINE WHERE
THE TIMEOUT ALWAYS HAPPENS

            logging.debug("starting prune\n")
            found = 1
            if (curplayer.name):
                logging.debug("pruning: " + curplayer.name + ":" +
curplayer.id +"\n")

            ...


------  Debug Output ------

# D 11-20 07:16PM 35.236 Starting pruneInactive
# D 11-20 07:16PM 35.236 Query is built
# D 11-20 07:16PM 35.236 Ready to start first prune
# E 11-20 07:16PM 38.266
Traceback (most recent call last):
  File "/base/python_lib/versions/1/google/appengine/ext/webapp/
__init__.py", line 499, in __call__
    handler.get(*groups)
  File "/base/data/home/apps/gas/363.329414350639462263/
serverhttp.py", line 1375, in get
    self.player.pruneInactive()
  File "/base/data/home/apps/gas/363.329414350639462263/
serverhttp.py", line 366, in pruneInactive
    for curplayer in query:
  File "/base/python_lib/versions/1/google/appengine/ext/db/
__init__.py", line 1323, in __iter__
    return self.run()
  File "/base/python_lib/versions/1/google/appengine/ext/db/
__init__.py", line 1315, in run
    return _QueryIterator(self._model_class, iter(self._get_query().Run
()))
  File "/base/python_lib/versions/1/google/appengine/api/
datastore.py", line 860, in Run
    return self._Run()
  File "/base/python_lib/versions/1/google/appengine/api/
datastore.py", line 882, in _Run
    _ToDatastoreError(err)
  File "/base/python_lib/versions/1/google/appengine/api/
datastore.py", line 1636, in _ToDatastoreError
    raise errors[err.application_error](err.error_detail)
InternalError: internal error



--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to