Context Management

This module defines a context object which holds on to all global state.

class support.context.Context(dev=False, stage_host=None)[source]

Context object is meant to be the clearinghouse for global data in an application written using SuPPort. There is only one active Context at a time. Access the context with infra.context.get_context().

Two categories of data in here:

  1. Global data used internally by the infrastructure.

2. Global data which would otherwise need to be kept track of by user code. (This stuff can be identified by the presence of getters)

There are many configuration attributes. They ALL go to a sane default, it is not necessary to touch them but they are available for advanced users.

appname
debug_errors
dev
disable_recent_cache()[source]

Disable caching of recent outgoing network requests. This will help to keep memory footprint small in applications where that is important.

get_connection(*a, **kw)[source]
greenlet_settrace

check if any greenlet trace function is registered

monitoring_greenlet
port
sampling
serve_ufork
set_config(config)[source]
set_greenlet_trace(value)[source]

turn on tracking of greenlet switches

set_monitoring_greenlet(val)[source]
set_sampling(val)[source]
set_stage_host(stage_host, stage_ip=None)[source]
stop()[source]

Stop any concurrently running tasks (threads or greenlets) associated with this Context object.

(e.g. sampling profiler thread, system monitor greenlet)

store_network_data(name, fd, direction, data)[source]
class support.context.StreamSketch[source]

Tracking useful attributes of a data stream. (e.g. cardinality, total count)

class LossyCounting(epsilon=0.001)[source]

Implements the “lossy counting” algorithm from “Approximate Frequency Counts over Data Streams” by Manku & Motwani

Experimentally run-time is between 1-3 microseconds on core i7

add(data)[source]
StreamSketch.add(data)[source]
StreamSketch.card()[source]
StreamSketch.heavy_hitters()[source]
support.context.counted(f)[source]
support.context.get_context()[source]
support.context.get_ip_from_hosts()[source]

get the current ip from the hosts file, without doing any DNS; available as a fallback

support.context.set_context(context)[source]
support.context.summarize(data, size=64)[source]