eww.stats

Eww’s stats thread & interface. Receives and processes stats requests.

This module also contains any helper functions for stats.

exception eww.stats.InvalidCounterOption[source]

Bases: exceptions.Exception

Raised when counter methods are called with invalid data

__weakref__

list of weak references to the object (if defined)

exception eww.stats.InvalidGraphDatapoint[source]

Bases: exceptions.Exception

Raised when stats.graph is called with invalid data

__weakref__

list of weak references to the object (if defined)

class eww.stats.Stat

Bases: tuple

Stat(name, type, action, value)

__getnewargs__()

Return self as a plain tuple. Used by copy and pickle.

__getstate__()

Exclude the OrderedDict from pickling

static __new__(_cls, name, type, action, value)

Create new instance of Stat(name, type, action, value)

__repr__()

Return a nicely formatted representation string

_asdict()

Return a new OrderedDict which maps field names to their values

classmethod _make(iterable, new=<built-in method __new__ of type object at 0x90aa40>, len=<built-in function len>)

Make a new Stat object from a sequence or iterable

_replace(_self, **kwds)

Return a new Stat object replacing specified fields with new values

action

Alias for field number 2

name

Alias for field number 0

type

Alias for field number 1

value

Alias for field number 3

class eww.stats.StatsThread(max_datapoints=500, timeout=1)[source]

Bases: eww.stoppable_thread.StoppableThread

StatsThread listens to STATS_QUEUE and processes incoming stats. As a StoppableThread subclass, this thread must check for the .stop_requested flag.

__init__(max_datapoints=500, timeout=1)[source]

Init.

Parameters:
  • max_datapoints (int) – The maximum number of graph datapoints to record. If this limit is hit, datapoints will be discard based on age, oldest-first.
  • timeout (float) – Frequency, in seconds, to check for a stop or remove request.
process_stat(msg)[source]

Accepts and processes stats messages.

Parameters:msg (Stat) – A populated Stat object.
Returns:None
run()[source]

Main thread loop.

eww.stats.counter_manipulation(stat)[source]

Backend to all counter changes.

Parameters:stat (Stat) – A populated Stat object.
Returns:None
eww.stats.decr(name, amount=1)[source]

Reduces a counter.

Parameters:
  • name (str) – The name of the counter to decrement.
  • amount (int) – The value to decrement name by.
eww.stats.graph(name, datapoint)[source]

Adds an X.Y datapoint.

Parameters:
  • name (str) – The name of the graph to record a datapoint for.
  • datapoint (tuple) – A tuple representing an (X, Y) datapoint.
Returns:

None

eww.stats.incr(name, amount=1)[source]

Increments a counter.

Parameters:
  • name (str) – The name of the counter to increment.
  • amount (int) – The amount to increment name by.
Returns:

None

eww.stats.memory_consumption()[source]

Returns memory consumption (specifically, max rss). Currently this uses the resource module, and is only available on Unix.

Returns:MaxRSS value. On Windows, this always returns 0.
Return type:int
eww.stats.put(name, amount=1)[source]

Puts a counter to a specific value.

Parameters:
  • name (str) – The name of the counter to set to a specific value.
  • amount (int) – The value to set name to.
Returns:

None