Troubleshooting

A collection of tips for how to solve problems that come up from time to time. Each is annotated with who gave the answer, so you can ask them for more help if needed.

What do you do if GoogleAppEngineLauncher dies without letting go of the most coveted port of all, 8080?

alpert:

$ lsof -i :8080
$ kill -9 <whichever PID you see>

What do you do if you get a "'module' object has no attribute 'xsrf'" error?

james: Stop and restart your app.

What do you do if you get a "[Errno 2] No such file or directory: '/Users/james/Sites/datastore/-Tmp-/dev_appserver.blobstore/dev~khan-academy/D/Dc7adYdDH0e_B3l5YbTuA=='" error?

james: You probably copied a datastore that referenced blobs that don't exist.  Go to your SDK console from your appengine launcher -> Datastore Viewer and delete all __BlobInfo__ entities.

What do you do when remote shell hangs when trying to fetch all when what you are trying to fetch is over 1k entities:

james: The remote shell has a 1k limit.  You can get around this by using: 
def incremental_fetch(query):
    i = 0
    batch_size = 500
    start_key = None
    all_entities = []
    while True:
        print i
        q = deepcopy(query)
        if start_key:
            q.filter("__key__ >", start_key)
        q.order("__key__")
        entities=q.fetch(batch_size)
        if len(entities):
            all_entities.extend(entities)
            start_key = entities[-1].key()
            i += batch_size
        else:
            break
    return all_entities

videos = incremental_fetch(Video.all())


How do I run an interactive debugger for app engine?

Throw this line into the point your want debugging to start:

    import pdb, sys; pdb.Pdb(stdin=sys.__stdin__, stdout=sys.__stdout__).set_trace()

You might have to run app engine from the console with dev_appserver.py to get this to work