Пример #1
0
    def modify_task_lease(self, app_id, http_data):
        """ 

    Args:
      app_id: The application ID.
      http_data: The payload containing the protocol buffer request.
    Returns:
      A tuple of a encoded response, error code, and error detail.
    """
        request = taskqueue_service_pb.TaskQueueModifyTaskLeaseRequest(
            http_data)
        response = taskqueue_service_pb.TaskQueueModifyTaskLeaseResponse()

        queue = self.get_queue(app_id, request.queue_name())
        task_info = {'id': request.task_name()}
        try:
            # The Python AppServer sets eta_usec with a resolution of 1 second,
            # so update_lease can't be used. It checks with millisecond precision.
            task = queue.update_task(Task(task_info), request.lease_seconds())
        except InvalidLeaseRequest as lease_error:
            error = taskqueue_service_pb.TaskQueueServiceError.TASK_LEASE_EXPIRED
            # The response requires ETA to be set before encoding.
            response.set_updated_eta_usec(0)
            return response.Encode(), error, str(lease_error)

        epoch = datetime.datetime.utcfromtimestamp(0)
        updated_usec = int(
            (task.leaseTimestamp - epoch).total_seconds() * 1000000)
        response.set_updated_eta_usec(updated_usec)
        return response.Encode(), 0, ""
Пример #2
0
    def modify_task_lease(self, app_id, http_data):
        """ 

    Args:
      app_id: The application ID.
      http_data: The payload containing the protocol buffer request.
    Returns:
      A tuple of a encoded response, error code, and error detail.
    """
        # TODO implement.
        request = taskqueue_service_pb.TaskQueueModifyTaskLeaseRequest(
            http_data)
        response = taskqueue_service_pb.TaskQueueModifyTaskLeaseResponse()
        return (response.Encode(), 0, "")