本文整理匯總了Python中google.appengine.api.taskqueue.Error方法的典型用法代碼示例。如果您正苦於以下問題:Python taskqueue.Error方法的具體用法?Python taskqueue.Error怎麽用?Python taskqueue.Error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類google.appengine.api.taskqueue
的用法示例。
在下文中一共展示了taskqueue.Error方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _AddUserRetrievalTask
# 需要導入模塊: from google.appengine.api import taskqueue [as 別名]
# 或者: from google.appengine.api.taskqueue import Error [as 別名]
def _AddUserRetrievalTask(self, task):
"""Helper to transactionally add the tasks.
Do not set transactional=True in the Task because Push Queues have a
5 Task per add limit when transactional=True per:
http://developers.google.com/appengine/docs/python/taskqueue/overview-push
Args:
task: Task or list of Tasks to retrieve domain users.
Raises:
re-raises any taskqueue errors raised.
"""
try:
Queue('retrieve-users-queue').add(task=task)
except TaskQueueError:
view_utils.FailRecallTask(
task_key_id=self._task_key_id,
reason_string='Failed to enqueue retrieve users tasks.')
raise
示例2: test_storage_server_error
# 需要導入模塊: from google.appengine.api import taskqueue [as 別名]
# 或者: from google.appengine.api.taskqueue import Error [as 別名]
def test_storage_server_error(self):
"""Assert that GS storage raises appropriate error when storage fails."""
# pretend that taskqueue addition fails
def _taskqueue_add_mock(*_args, **_kwargs):
raise taskqueue.Error()
self.mock(taskqueue, 'add', _taskqueue_add_mock)
# make a GCS-sized request
big_datum = pad_string('gigas')
namespace = 'default-gzip'
request = self.store_request(namespace, big_datum)
self.mock(gcs, 'get_file_info', get_file_info_factory(big_datum))
# should raise InternalServerErrorException
with self.call_should_fail('500'):
self.call_api('finalize_gs_upload', message_to_dict(request), 200)
示例3: testLeaseFreedOnTaskqueueUnavailable
# 需要導入模塊: from google.appengine.api import taskqueue [as 別名]
# 或者: from google.appengine.api.taskqueue import Error [as 別名]
def testLeaseFreedOnTaskqueueUnavailable(self):
handler, _ = self._create_handler()
with mock.patch("mapreduce"
".handlers.MapperWorkerCallbackHandler._add_task") as add:
add.side_effect = taskqueue.Error
self.assertRaises(taskqueue.Error, handler.post)
# No new task in taskqueue.
stub = apiproxy_stub_map.apiproxy.GetStub("taskqueue")
self.assertEqual(0, len(stub.GetTasks("default")))
shard_state = model.ShardState.get_by_shard_id(self.shard_state.shard_id)
self.assertTrue(shard_state.acquired_once)
# Besides these fields, all other fields should be the same.
shard_state.acquired_once = self.shard_state.acquired_once
shard_state.update_time = self.shard_state.update_time
self.assertEqual(str(self.shard_state), str(shard_state))
示例4: _EnqueueMasterRecallTask
# 需要導入模塊: from google.appengine.api import taskqueue [as 別名]
# 或者: from google.appengine.api.taskqueue import Error [as 別名]
def _EnqueueMasterRecallTask(self, owner_email, message_criteria,
task_key_id):
"""Add master recall task with error handling.
Args:
owner_email: String email address of user running this recall.
message_criteria: String criteria (message-id) to recall.
task_key_id: Int unique id of the parent task.
Raises:
re-raises any task queue errors.
"""
task_name = '%s_%s' % (
view_utils.CreateSafeUserEmailForTaskName(owner_email),
view_utils.GetCurrentDateTimeForTaskName())
master_task = Task(name=task_name,
params={'owner_email': owner_email,
'task_key_id': task_key_id,
'message_criteria': message_criteria},
target='0.recall-backend',
url='/backend/recall_messages')
try:
master_task.add(queue_name='recall-messages-queue')
except TaskQueueError:
view_utils.FailRecallTask(task_key_id=task_key_id,
reason_string='Failed to enqueue master task.')
raise