Created
June 4, 2014 06:56
-
-
Save erlichmen/d81501cafb59bf2a9b97 to your computer and use it in GitHub Desktop.
Better deferred handler names for debugging and appstats
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- url: /_ah/queue/deferred/.* | |
script: google.appengine.ext.deferred.application |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.appengine.ext import deferred | |
def do_defer(obj, *args, **kwargs): | |
_DEFAULT_URL = "/_ah/queue/deferred" | |
tag = kwargs.pop("_tag") if kwargs.get('_tag') else None | |
if not tag and kwargs.get('_queue'): | |
tag = kwargs.get('_queue') | |
kwargs['_url'] = '%s/%s' % (_DEFAULT_URL, tag or 'notag') | |
deferred.defer(obj, *args, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using deferred in App Engine you have the problem that all diagnostic is on the same handler although you might be using it for different functionality.
This means in the the event log, appstat and requests diagnostics (on the main dashboard page) you will see everything under the /_ah/queue/deferred entry.
In order to get better context to which each defer belongs use do_defer instead of deferred.defer and add the above yaml code to your app.yaml.
The code will add the queue name to the handler path (e.g. /_ah/queue/deferred/my-queue) or you can pass the _tag property (do_defer(my_method, _tag='method-tag')) to control the path text.