Wednesday, April 11, 2012

Django Google App Engine - Proper way to setup stub queues for management commands

I have a custom setup command that generates a bunch of initial seed/test data. We currently have some signals setup to kick off some (non-critical) deferred queue logic. What is the proper way to mock out the queues so I do not see the UnknownQueue error below?




Traceback (most recent call last):



File "../models/init.py", line 207, in some_model_post_processing
deferred.defer(some_method,param1, param2,_queue="queue-create")



File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/deferred/deferred.py", line 256, in defer
return task.add(queue, transactional=transactional)



File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/taskqueue/taskqueue.py", line 1008, in add
return Queue(queue_name).add(self, transactional=transactional)



File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/taskqueue/taskqueue.py", line 1546, in add
self._AddTasks(tasks, transactional, self._FillAddPushTasksRequest)



File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/taskqueue/taskqueue.py", line 1609, in __AddTasks
raise exception
UnknownQueueError







So i was just able to get "mock" the queues but is there a way to get the real queues initialized (aka ones that will actually run)?



Code that will initialize test mock queues:



path_to_queue_yaml= xxxxx
tb = testbed.Testbed()
tb.activate()
tb.init_taskqueue_stub(root_path=path_to_queue_yaml)




No comments:

Post a Comment