The
QueueStatistics
class represents the current state of a queue.
QueueStatistics
is provided by the
google.appengine.api.taskqueue
module.
- Introduction
- Properties
- Class methods:
Introduction
The
QueueStatistics
object allows you to fetch statistics and
information about your task queue from within your application. The statistics
include information such as the number of tasks currently in the queue, how many
tasks were executed in the last minute, and the
enforced rate
.
The statistics returned should be treated as approximations to help manage the queue. Furthermore, the statistics can lag the current state of the queue by up to 30 seconds.
You get the
QueueStatistics
object for a queue by invoking
fetch_statistics()
.
Alternatively, you can get one or more
QueueStatistics
objects by invoking
QueueStatistics.fetch()
.
Properties
A
QueueStatistics
instance has the following properties:
-
queue
-
The queue that this
QueueStatistics
is for. -
tasks
-
The number of tasks remaining in the queue.
-
oldest_eta_usec
-
A recent estimate of the ETA of the oldest non-completed task in the queue, or
None
if there were no non-completed tasks found in the queue. The valueNone
indicates that the queue has no backlog; that is, the queue is empty or only contains tasks with an ETA in the future.The ETA represents the time at which a push queue task is eligible to begin execution or a pull queue task is eligible to be leased. It is expressed as microseconds since January 1st 1970. App Engine will not execute a task before its ETA.
-
executed_last_minute
-
For push queues, this value indicates the number of tasks executed in the last minute. For pull queues, this value indicates the number of tasks leased in the last minute.
-
in_flight
-
For push queues, the number of tasks that are currently executing. (This property is not revelevant for pull queues.)
-
enforced_rate
-
For push queues, the current enforced rate, expressed as tasks per second. (This property is not revelevant for pull queues.) The enforced rate is the actual rate at which tasks are being processed after any throttling done by App Engine to prevent the queue from overwhelming your application. The enforced rate may be smaller than the rate you specify in the queue configuration. (If the enforced rate is too small, you can change performance settings for your application.)
Class Methods
The
QueueStatistics
class has these class methods:
- fetch ( queue_or_queues )
-
You use
QueueStatistics.fetch()
to getQueueStatistics
objects for the queues you are interested in. You can specify one or more queues. For example,statsList = taskqueue.QueueStatistics.fetch([taskqueue.Queue("foo"), taskqueue.Queue("bar")])
.Arguments
- 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 a list of queues, you can supply an iterable list ofQueue
instances or an iterable list of queue names.
If a single queue was specified in the call, the return value is a
QueueStatistics
instance for that queue. If a list of queues was specified in the call, the return value is a list of ofQueueStatistics
objects, one for each queue in the order requested. - fetch_async ( queue_or_queues , rpc = None )
-
Asynchronously returns queue details for multiple queues. (You can specify one or more queues.) For example,
rpc = taskqueue.create_rpc(deadline=1.0) taskqueue.QueueStatistics.fetch_async([taskqueue.Queue("foo"), taskqueue.Queue("bar")],rpc) statsList = rpc.get_result()
Arguments
- 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 a list of queues, you can supply an iterable list ofQueue
instances or an iterable list of queue names. - rpc
- The RPC object used for asynchronous operation.
Returns a RPC object, on which you call
get_result
to obtain the result. If a single queue was specified in the call, the result of this is aQueueStatistics
instance for that queue. If a list of queues was specified in the call, the result is a list ofQueueStatistics
objects, one for each queue in the order requested.