当前位置: 首页>>代码示例>>Python>>正文


Python taskqueue.Error方法代码示例

本文整理汇总了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 
开发者ID:google,项目名称:googleapps-message-recall,代码行数:22,代码来源:backend_views.py

示例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) 
开发者ID:luci,项目名称:luci-py,代码行数:18,代码来源:handlers_endpoints_v1_test.py

示例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)) 
开发者ID:GoogleCloudPlatform,项目名称:appengine-mapreduce,代码行数:19,代码来源:handlers_test.py

示例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 
开发者ID:google,项目名称:googleapps-message-recall,代码行数:29,代码来源:frontend_views.py


注:本文中的google.appengine.api.taskqueue.Error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。