google.appengine.api.taskqueue package

Summary

Task Queue API module.

Sub Modules

google.appengine.api.taskqueue.taskqueue

Task Queue API.

Contents

exception google.appengine.api.taskqueue.BadTaskStateErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

The task is in the wrong state for the requested operation.

google.appengine.api.taskqueue.BadTransactionState

alias of BadTransactionStateError

exception google.appengine.api.taskqueue.BadTransactionStateErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

The state of the current transaction does not permit this operation.

exception google.appengine.api.taskqueue.DatastoreErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

There was a datastore error while accessing the queue.

exception google.appengine.api.taskqueue.DuplicateTaskNameErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

Two tasks have the same name.

When adding multiple tasks to a queue in a batch, more than one task cannot have the same name.

exception google.appengine.api.taskqueue.Errorsource

Bases: exceptions.Exception

Base class for exceptions in this module.

exception google.appengine.api.taskqueue.InternalErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

An internal error occurred while accessing this queue.

If the problem continues, contact the App Engine team through the support forum. Be sure to include a description of your problem.

exception google.appengine.api.taskqueue.InvalidQueueErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

The queue’s configuration is invalid.

exception google.appengine.api.taskqueue.InvalidQueueNameErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.InvalidQueueError

The name of the queue is invalid.

exception google.appengine.api.taskqueue.InvalidTaskErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

The parameters, headers, or method of the task is invalid.

exception google.appengine.api.taskqueue.InvalidTaskNameErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.InvalidTaskError

The name of the task is invalid.

exception google.appengine.api.taskqueue.InvalidUrlErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.InvalidTaskError

The relative URL used for the task is invalid.

exception google.appengine.api.taskqueue.PermissionDeniedErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

The requested operation is not allowed for this app.

exception google.appengine.api.taskqueue.TaskAlreadyExistsErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.InvalidTaskError

The task already exists. It has not yet run.

exception google.appengine.api.taskqueue.TaskTooLargeErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.InvalidTaskError

The task is too large with its headers and payload.

exception google.appengine.api.taskqueue.TombstonedTaskErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.InvalidTaskError

The task has been tombstoned.

A task with the same name was previously executed in the queue; names should be unique within a queue.

exception google.appengine.api.taskqueue.TooManyTasksErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

Too many tasks were present in a single function call.

exception google.appengine.api.taskqueue.TransientErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

A transient error occurred while accessing the queue. Try again later.

exception google.appengine.api.taskqueue.UnknownQueueErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

The queue specified is unknown.

exception google.appengine.api.taskqueue.InvalidLeaseTimeErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

The lease time period is invalid.

exception google.appengine.api.taskqueue.InvalidMaxTasksErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

The requested maximum number of tasks in lease_tasks is invalid.

exception google.appengine.api.taskqueue.InvalidDeadlineErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

The requested deadline in lease_tasks is invalid.

exception google.appengine.api.taskqueue.InvalidQueueModeErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

Invokes a pull queue operation on a push queue or vice versa.

exception google.appengine.api.taskqueue.TransactionalRequestTooLargeErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.TaskTooLargeError

The total size of this transaction (including tasks) was too large.

exception google.appengine.api.taskqueue.TaskLeaseExpiredErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

The task lease could not be renewed because it had already expired.

exception google.appengine.api.taskqueue.QueuePausedErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

The queue is paused and cannot process modify task lease requests.

exception google.appengine.api.taskqueue.InvalidEtaErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.InvalidTaskError

The task’s ETA is invalid.

exception google.appengine.api.taskqueue.InvalidTagErrorsource

Bases: google.appengine.api.taskqueue.taskqueue.Error

The specified tag is invalid.

class google.appengine.api.taskqueue.Queue(name='default')source

Bases: object

Represents a queue.

The Queue class is used to prepare tasks for offline execution by App Engine.

A queue object is instantiated by name. The name must correspond either to the default queue (provided by the system) or a user-defined queue as specified in the application’s queue.yaml configuration file. The queue object can then be used to insert new task instances for offline execution by App Engine.

Multiple queue objects can correspond to the same underlying system queue. However, a single task object can only be added to one queue.

add(task, transactional=False)source

Adds a task or list of tasks into this queue.

If a list of more than one tasks is given, a raised exception does not guarantee that no tasks were added to the queue (unless transactional is set to True). To determine which tasks were successfully added when an exception is raised, check the Task.was_enqueued property.

Push tasks, or those with a method not equal to pull cannot be added to queues in pull mode. Similarly, pull tasks cannot be added to queues in push mode.

If a TaskAlreadyExistsError or TombstonedTaskError is raised, the caller can be guaranteed that for each one of the provided tasks, either the corresponding task was successfully added, or a task with the given name was successfully added in the past.

Parameters
  • task – A task instance or a list of task instances that will be added to the queue. If task is set to a list of task objects, all tasks are added to the queue. If Transactional=True, then all of the tasks are added in the same active Datastore transaction, and if any of the tasks cannot be added to the queue, none of the tasks are added to the queue, and the Datastore transaction will fail. If transactional=False, a failure to add any task to the queue will raise an exception, but other tasks will be added to the queue.

  • transactional – If True, transactional tasks will be added to the queue but cannot be run or leased until after the transaction succeeds. If the transaction fails then the tasks will be removed from the queue (and therefore will never run). If False, the added tasks are available to run immediately; any enclosing transaction’s success or failure is ignored.

Returns

The task or list of tasks that was supplied to this method. Successfully queued tasks will have a valid queue name and task name after the call; these task objects are marked as queued and cannot be added again.

Raises
  • BadTaskStateError – If the task has already been added to a queue.

  • BadTransactionStateError – If the transactional argument is True but this call is being made outside of the context of a transaction.

  • DuplicateTaskNameError – If a task name is repeated in the request.

  • InvalidTaskNameError – If a task name is provided but is not valid.

  • InvalidTaskError – If both push and pull tasks exist in the task list.

  • InvalidQueueModeError – If a pull task is added to a queue in push mode, or if a push task is added to a queue in pull mode.

  • TaskAlreadyExistsError – If a task with the same name as a given name has previously been added to the queue.

  • TombstonedTaskError – If a task with the same name as a given name has previously been added to the queue and deleted.

  • TooManyTasksError – If a task contains more than MAX_TASKS_PER_ADD tasks.

  • TransactionalRequestTooLargeError – If transactional is True and the total size of the tasks and supporting request data exceeds the MAX_TRANSACTIONAL_REQUEST_SIZE_BYTES quota.

  • Error-subclass on application errors.

add_async(task, transactional=False, rpc=None)source

Asynchronously adds a task or list of tasks into this queue.

This function is identical to add() except that it returns an asynchronous object. You can call get_result() on the return value to block on the call.

Parameters
  • task – A task instance or a list of task instances that will be added to the queue. If task is a list of task objects, all tasks are added to the queue. If Transactional=True, then all of the tasks are added in the same active Datastore transaction, and if any of the tasks cannot be added to the queue, none of the tasks are added to the queue and the Datastore transaction will fail. If transactional=False, a failure to add a task to the queue will raise an exception, but other tasks will be enqueued.

  • transactional – If True, transactional tasks will be added to the queue but cannot be run or leased until after the transaction succeeds. If the transaction fails, the tasks will be removed from the queue (and therefore will never run). If False, the added tasks are available to run immediately; any enclosing transaction’s success or failure is ignored.

  • rpc – An optional UserRPC object.

Returns

A UserRPC object. Call get_result() to complete the RPC and obtain the task or list of tasks that was supplied to this method. Successfully queued tasks will have a valid queue name and task name after the call; such task objects are marked as queued and cannot be added again.

Raises
delete_tasks(task)source

Deletes a task or list of tasks in this queue.

When multiple tasks are specified, an exception will be raised if any individual task fails to be deleted. Check the task.was_deleted property.

The task name is the only task attribute that is used to select tasks for deletion. If any task exists that is unnamed or with the was_deleted property set to True, a BadTaskStateError will be raised immediately.

Parameters

task – A task instance or a list of task instances that will be deleted from the queue.

Returns

The task or list of tasks passed into this call.

Raises
  • BadTaskStateError – If the tasks to be deleted do not have task names or have already been deleted.

  • DuplicateTaskNameError – If a task is repeated in the request.

  • Error-subclass on application errors.

delete_tasks_async(task, rpc=None)source

Asynchronously deletes a task or list of tasks in this queue.

The task name is the only task attribute that is used to select tasks for deletion.

This function is identical to delete_tasks() except that it returns an asynchronous object. You can call get_result() on the return value to block on the call.

Parameters
  • task – A task instance or a list of task instances that will be deleted from the queue.

  • rpc – An optional UserRPC object.

Returns

A UserRPC object. Call get_result() to complete the RPC and obtain the task or list of tasks passed into this call.

Raises
delete_tasks_by_name(task_name)source

Deletes a task or list of tasks in this queue, by name.

When multiple tasks are specified, an exception will be raised if any individual task fails to be deleted.

Parameters

task_name – A string corresponding to a task name, or an iterable of strings corresponding to task names.

Returns

If an iterable, other than string, is provided as input, a list of task objects is returned, one for each task name in the order requested. The Task.was_deleted property will be True for each task deleted by this call, and will be False for unknown and tombstoned tasks.

Otherwise, if a single string was provided as input, a single task object is returned.

Raises
delete_tasks_by_name_async(task_name, rpc=None)source

Asynchronously deletes a task or list of tasks in this queue, by name.

This function is identical to delete_tasks_by_name() except that it returns an asynchronous object. You can call get_result() on the return value to block on the call.

Parameters
  • task_name – A string corresponding to a task name, or an iterable of strings corresponding to task names.

  • rpc – An optional UserRPC object.

Returns

A UserRPC object. Call get_result() to complete the RPC and obtain the result.

If an iterable, other than string, is provided as input, the result will be a list of of task objects, one for each task name in the order requested. The Task.was_deleted property will be True for each task deleted by this call, and will be False for unknown and tombstoned tasks.

Otherwise, if a single string was provided as input, then the result will be a single task object.

Raises

DuplicateTaskNameError – If a task name is repeated in the request.

fetch_statistics(deadline=10)source

Gets the current details about this queue.

Parameters

deadline – The maximum number of seconds to wait before aborting the method call.

Returns

A QueueStatistics instance that contains information about this queue. Error-subclass on application errors.

fetch_statistics_async(rpc=None)source

Asynchronously gets the current details about this queue.

Parameters

rpc – An optional UserRPC object.

Returns

A UserRPC object. Call get_result() to complete the RPC and obtain a QueueStatistics instance that contains information about this queue.

lease_tasks(lease_seconds, max_tasks, deadline=10)source

Leases a number of tasks from the queue for a period of time.

This method can only be performed on a pull queue. Any non-pull tasks in the pull queue will be converted into pull tasks when being leased. If fewer than the specified number of max_tasks are available, all available tasks will be returned. The lease_tasks method supports leasing at most 1000 tasks for no longer than a week in a single call.

Parameters
  • lease_seconds – Number of seconds to lease the tasks, up to one week (604,800 seconds). Must be a positive integer.

  • max_tasks – The maximum number of tasks to lease from the pull queue, up to 1000 tasks.

  • deadline – The maximum number of seconds to wait before aborting the method call.

Returns

A list of tasks leased from the queue.

Raises
  • InvalidLeaseTimeError – If lease_seconds is not a valid float or integer number or is outside the valid range.

  • InvalidMaxTasksError – If max_tasks is not a valid integer or is outside the valid range.

  • InvalidQueueModeError – If invoked on a queue that is not in pull mode.

  • Error-subclass on application errors.

lease_tasks_async(lease_seconds, max_tasks, rpc=None)source

Asynchronously leases a number of tasks from the queue.

This method can only be performed on a pull queue. Attempts to lease tasks from a push queue results in an InvalidQueueModeError. All non-pull tasks in the pull queue will be converted into pull tasks when leased. If fewer than the specified value of max_tasks are available, all available tasks on a best-effort basis are returned. The lease_tasks_async method supports leasing at most 1000 tasks for no longer than a week in a single call.

This function is identical to lease_tasks() except that it returns an asynchronous object. You can call get_result() on the return value to block on the call.

Parameters
  • lease_seconds – Number of seconds to lease the tasks, up to one week (604,800 seconds). Must be a positive integer.

  • max_tasks – Maximum number of tasks to lease from the pull queue, up to 1000 tasks.

  • rpc – An optional UserRPC object.

Returns

A UserRPC object. Call get_result() to complete the RPC and obtain the list of tasks leased from the queue.

Raises
  • InvalidLeaseTimeError – If lease_seconds is not a valid float or integer number or is outside the valid range.

  • InvalidMaxTasksError – If max_tasks is not a valid integer or is outside the valid range.

lease_tasks_by_tag(lease_seconds, max_tasks, tag=None, deadline=10)source

Leases tasks with the same tag from the queue.

If a tag is specified, tasks with that tag are leased for a specified period of time. If a tag is not specified, the tag of the queue’s oldest task (specified by the eta) will be used.

This method can only be performed on a pull queue. Any non-pull tasks in the pull queue will be converted into pull tasks when being leased. If fewer than the specified value of max_tasks are available, all available tasks will be returned. The lease_tasks method supports leasing at most 1000 tasks for no longer than a week in a single call.

Parameters
  • lease_seconds – Number of seconds to lease the tasks.

  • max_tasks – The maximum number of tasks to lease from the pull queue.

  • tag – The tag to query for, or None to group by the first available tag.

  • deadline – The maximum number of seconds to wait before aborting the method call.

Returns

A list of tasks leased from the queue.

Raises
  • InvalidLeaseTimeError – If lease_seconds is not a valid float or integer number or is outside the valid range.

  • InvalidMaxTasksError – If max_tasks is not a valid integer or is outside the valid range.

  • InvalidQueueModeError – If invoked on a queue that is not in pull mode.

  • Error-subclass on application errors.

lease_tasks_by_tag_async(lease_seconds, max_tasks, tag=None, rpc=None)source

Asynchronously leases tasks with the same tag from the queue.

If a tag is specified, tasks with that tag are leased for a specified period of time. If a tag is not specified, the best-effort oldest tag of the queue’s oldest task (specified by the eta) will be used.

This function is identical to lease_tasks_by_tag() except that it returns an asynchronous object. You can call get_result() on the return value to block on the call.

Parameters
  • lease_seconds – Number of seconds to lease the tasks.

  • max_tasks – The maximum number of tasks to lease from the pull queue.

  • tag – The tag to query for, or None to group by the first available tag.

  • rpc – An optional UserRPC object.

Returns

A UserRPC object. Call get_result() to complete the RPC and obtain the list of tasks leased from the queue.

Raises
  • InvalidLeaseTimeError – If lease_seconds is not a valid float or integer number or is outside the valid range.

  • InvalidMaxTasksError – If max_tasks is not a valid integer or is outside the valid range.

modify_task_lease(task, lease_seconds)source

Modifies the lease of a task in this queue.

Parameters
  • task – A task instance that will have its lease modified.

  • lease_seconds – Number of seconds, from the current time, that the task lease will be modified to. If lease_seconds is 0, the task lease is removed and the task will be available for leasing again using the lease_tasks method.

Raises
  • TypeError – If lease_seconds is not a valid float or integer.

  • InvalidLeaseTimeError – If lease_seconds is outside of the valid range.

  • Error-subclass on application errors.

name

Returns the name of this queue.

purge()source

Removes all of the tasks in this queue.

Purging the queue takes time, regardless of the queue size. Tasks continue to run until the backends recognize that the queue has been purged. This operation is permanent; purged tasks cannot be recovered.

Raises

Error-subclass on application errors.

class google.appengine.api.taskqueue.QueueStatistics(queue, tasks, oldest_eta_usec=None, executed_last_minute=None, in_flight=None, enforced_rate=None)source

Bases: object

Represents the current state of a queue.

classmethod fetch(queue_or_queues, deadline=10)source

Get the queue details for multiple queues.

Use QueueStatistics.fetch() to get QueueStatistics objects for the queues you are interested in. You can specify one or more queues.

Example:

statsList = taskqueue.QueueStatistics.fetch([taskqueue.Queue("foo"),
                                             taskqueue.Queue("bar")])
Parameters
  • queue_or_queues – The queue or list of queues for which you are obtaining statistics. If you are retrieving statistics for a single queue, you can supply either a queue instance or the name of the queue. If you are retrieving statistics for a list of queues, you can supply an iterable list of queue instances or an iterable list of queue names.

  • deadline – The maximum number of seconds to wait before aborting the method call.

Returns

If an iterable (other than string) is provided as input, a list of of QueueStatistics objects will be returned, one for each queue in the order requested.

Otherwise, if a single item was provided as input, then a single QueueStatistics object will be returned.

Raises
  • TypeError – If queue_or_queues is not a queue instance, string, an iterable containing only queue instances, or an iterable containing only strings.

  • Error-subclass on application errors.

classmethod fetch_async(queue_or_queues, rpc=None)source

Asynchronously get the queue details for multiple queues.

Example:

rpc = taskqueue.create_rpc(deadline=1.0)
taskqueue.QueueStatistics.fetch_async([taskqueue.Queue("foo"),
                                        taskqueue.Queue("bar")], rpc)
statsList = rpc.get_result()
Parameters
  • queue_or_queues – The queue or list of queues for which you are obtaining statistics. If you are retrieving statistics for a single queue, you can supply either a queue instance or the name of the queue. If you are retrieving a list of queues, you can supply an iterable list of queue instances or an iterable list of queue names.

  • rpc – An optional UserRPC object.

Returns

A UserRPC object. Call get_result() to complete the RPC and obtain the result.

If an iterable (other than string) is provided as input, the result will be a list of of QueueStatistics objects, one for each queue in the order requested.

Otherwise, if a single item was provided as input, then the result will be a single QueueStatistics object.

Raises

TypeError – If queue_or_queues is not a queue instance, string, an iterable containing only queue instances, or an iterable containing only strings.

class google.appengine.api.taskqueue.Task(payload=None, **kwargs)source

Bases: object

Represents a single task on a queue.

The Task class enables an application to queue background work. Work is done through webhooks that process tasks pushed from a push queue, or workers that manually pull tasks from a pull queue.

In push queues, most tasks are delivered in best-effort order of ETA.

Webhooks that fail cause tasks to be retried at a later time. You can configure the rate and number of retries for failed tasks. You can specify webhook URLs directly for push tasks. You can also use the default URL scheme, which translates task names into URLs that are relative to a queue’s base path. A default queue is also provided for simple usage.

In pull queues, workers are responsible for leasing tasks, processing them, and deleting them after processing. You can configure the number of task retries, which is based on how many times the task has been leased. You can define multiple queues with independent throttling controls.

You set the various properties for a task in the constructor. Once the Task object is instantiated, you insert that task into a queue. A task instance can be inserted into one queue only.

add(queue_name='default', transactional=False)source

Adds this task to a queue. See Queue.add.

add_async(queue_name='default', transactional=False, rpc=None)source

Asynchronously adds this task to a queue. See Queue.add_async.

eta

Returns a datetime.datatime when this task will run or be leased.

eta_posix

Returns a POSIX timestamp of when this task will run or be leased.

extract_params()source

Returns the parameters for this task.

If the same name parameter has several values, then the value is a list of strings. For POST requests and pull tasks, the parameters are extracted from the task payload; for all other methods, the parameters are extracted from the URL query string.

Returns

A dictionary of strings that map parameter names to their values as strings. If the same name parameter has several values, the value will be a list of strings. For POST requests and pull tasks, the parameters are extracted from the task payload. For all other methods, the parameters are extracted from the URL query string. An empty dictionary is returned if the task contains an empty payload or query string.

Raises

ValueError – If the payload does not contain valid application/x-www-form-urlencoded data (for POST requests and pull tasks) or the URL does not contain a valid query (all other requests).

headers

Returns a copy of the HTTP headers for this task (push tasks only).

method

Returns the method to use for this task.

name

Returns the name of this task.

on_queue_url

Returns True if task runs on queue’s default URL (push tasks only).

payload

Returns the payload to be used when the task is invoked (can be None).

queue_name

Returns the name of the queue with which this task is associated.

retry_count

Returns the number of retries or leases attempted on the task.

retry_options

Returns any or all the TaskRetryOptions tasks.

size

Returns the size of this task in bytes.

tag

Returns the tag for this task.

target

Returns the target for this task.

url

Returns the relative URL for this task (push tasks only).

was_deleted

Returns True if this task was successfully deleted.

was_enqueued

Returns True if this task has been inserted into a queue.

class google.appengine.api.taskqueue.TaskRetryOptions(**kwargs)source

Bases: object

The options used to decide when a failed task will be retried.

Tasks executing in the task queue can fail for many reasons. If a task fails to execute, which is indicated by returning any HTTP status code outside of the range 200-299, App Engine retries the task until it succeeds. By default, the system gradually reduces the retry rate to avoid flooding your application with too many requests, but schedules retry attempts to recur at a maximum of once per hour until the task succeeds. 503 errors, however, are treated as special cases and should not be returned by user code.

The TaskRetryOptions class provides the properties that you can use to decide when to retry a failed task at runtime.

max_backoff_seconds

The maximum number of seconds to wait before retrying a task.

max_doublings

The number of times that the retry interval will be doubled.

min_backoff_seconds

The minimum number of seconds to wait before retrying a task.

task_age_limit

The number of seconds after which a failed task will not be retried.

task_retry_limit

The number of times that a failed task will be retried.

google.appengine.api.taskqueue.add(*args, **kwargs)source

Convenience method that creates a task and adds it to a queue.

All parameters are optional.

Push tasks cannot be added to queues in pull mode. Similarly, pull tasks cannot be added to queues in push mode.

Parameters
  • payload – The payload data for this task that will be delivered to the webhook or backend as the HTTP request body (for push queues) or fetched by workers as part of the response from lease_tasks() (for pull queues). This argument is only allowed for POST and PUT methods and pull tasks.

  • queue_name – Name of queue to insert task into. If a name is not supplied, defaults to the default queue.

  • name – Name to give the task; if not specified, a name will be auto-generated when added to a queue and assigned to this object. The name must match the _TASK_NAME_PATTERN regular expression.

  • method – Method to use when accessing the webhook; the default value is POST. Other accepted values are GET, PUT, DELETE, HEAD, or PULL. Do not specify a method for push tasks, as the method will default to POST and post assigned tasks to the web hook at the url you specify. If you set the method to PULL, the task will not be automatically delivered to the webhook; instead, it will remain in the queue until leased.

  • url – Relative URL where the webhook that should handle this task is located for this application. You can use a query string unless this argument is used in a POST method. You cannot use this argument in a pull task.

  • headers – Dictionary of headers to pass to the webhook. Values in the dictionary can be iterable to indicate repeated header fields. If you do not specify a Content-Type header for a PUSH method, the default header (text/plain) will be used. If you specify a Host header for a PUSH method, do not specify a target argument. You cannot use a header argument in a pull task. Any headers that use the X-AppEngine prefix will also be dropped.

  • params – Dictionary of parameters to use for this task. For POST and pull requests, the values in the dictionary can be iterable to indicate repeated parameters, and these parameters will be encoded as application/x-www-form-urlencoded and set to the payload. For both POST and pull requests, do not specify parameters if you have already specified a payload. For PUT requests, parameters are converted to a query string if the URL contains a query string, or if the task already has a payload. For PUT requests, do not specify parameters if the URL already contains a query string and the method is GET. For all other methods, the parameters will be converted to a query string.

  • transactional – Optional. If True, adds tasks if and only if the enclosing transaction is successfully committed. An error will be returned if this argument is set to True in the absence of an enclosing transaction. If False, adds the tasks immediately, ignoring any enclosing transaction’s success or failure.

  • countdown – Time in seconds into the future that this task should run or be leased. Defaults to zero. Do not specify this argument if you specified an eta.

  • eta – A datetime.datetime that specifies the absolute earliest time at which the task should run. You cannot specify this argument if the countdown argument is specified. This argument can be time zone-aware or time zone-naive, or set to a time in the past. If the argument is set to None, the default value is now. For pull tasks, no worker can lease the task before the time indicated by the eta argument.

  • retry_options – TaskRetryOptions used to control when the task will be retried if it fails. For pull tasks, you can only specify the task_retry_limit option to specify the number of times that a task can be leased before it is deleted from the queue. For push tasks, you can specify the min_backoff_seconds, max_backoff_seconds, task_age_limit, max_doublings, and task_retry_limit options.

  • tag – The tag to be used when grouping by tag (pull tasks only).

  • target – Push tasks only; specifies the alternate version or backend on which to run this task, or DEFAULT_APP_VERSION to run on the application’s default version. You can specify a module or version, a frontend version, or a backend on which to run this task. The string that you specify will be prepended to the domain name of your app. If you specify the target argument, do not specify a Host header in the dictionary for the headers argument.

Returns

The task that was added to the queue.

Raises
google.appengine.api.taskqueue.create_rpc(deadline=None, callback=None)source

Creates an RPC object for use with the Task Queue API.

Parameters
  • deadline – Optional deadline in seconds for the operation; the default value is a system-specific deadline, which is typically 5 seconds. After the deadline, a DeadlineExceededError error will be returned.

  • callback – Optional function to be called with the Task Queue service returns results successfully when get_result(), check_success(), or wait() is invoked on the RPC object. The function is called without arguments. The function is not called in a background process or thread; the function is only called when one of the above methods is called by the application. The function is called even if the request fails or the RPC deadline elapses.

Returns

An apiproxy_stub_map.UserRPC object specialized for this service.