helpers/_docs_/index.html

724 lignes
72 KiB
HTML

<!DOCTYPE html>
<html class="writer-html4" lang="en" >
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to helpers’s documentation! &mdash; helpers documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="#" class="icon icon-home" alt="Documentation Home"> helpers
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<!-- Local TOC -->
<div class="local-toc"><ul>
<li><a class="reference internal" href="#">Welcome to helpers’s documentation!</a><ul>
<li><a class="reference internal" href="#helpers-helpers">helpers (Helpers)</a></li>
</ul>
</li>
<li><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li>
</ul>
</div>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="#">helpers</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="#" class="icon icon-home"></a> &raquo;</li>
<li>Welcome to helpers’s documentation!</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/index.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="module-helpers">
<span id="welcome-to-helpers-s-documentation"></span><h1>Welcome to helpers’s documentation!<a class="headerlink" href="#module-helpers" title="Permalink to this headline"></a></h1>
<div class="section" id="helpers-helpers">
<h2>helpers (Helpers)<a class="headerlink" href="#helpers-helpers" title="Permalink to this headline"></a></h2>
<p><strong>Author:</strong></p>
<ul class="simple">
<li>Dirk Alders &lt;<a class="reference external" href="mailto:sudo-dirk&#37;&#52;&#48;mount-mockery&#46;de">sudo-dirk<span>&#64;</span>mount-mockery<span>&#46;</span>de</a>&gt;</li>
</ul>
<p><strong>Description:</strong></p>
<blockquote>
<div>This module supports functions and classes which don’t have an own Module (yet).</div></blockquote>
<p><strong>Submodules:</strong></p>
<ul class="simple">
<li><a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a></li>
<li><a class="reference internal" href="#helpers.continues_statistic_multivalue" title="helpers.continues_statistic_multivalue"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic_multivalue</span></code></a></li>
<li><a class="reference internal" href="#helpers.direct_socket_client" title="helpers.direct_socket_client"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_client</span></code></a></li>
<li><a class="reference internal" href="#helpers.direct_socket_server" title="helpers.direct_socket_server"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_server</span></code></a></li>
<li><a class="reference internal" href="#helpers.ringbuffer" title="helpers.ringbuffer"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.ringbuffer</span></code></a></li>
</ul>
<p><strong>Unittest:</strong></p>
<blockquote>
<div>See also the <a class="reference download internal" download="" href="_downloads/fc87e95cc505cb0c7a476506dac46609/unittest.pdf"><code class="xref download docutils literal notranslate"><span class="pre">unittest</span></code></a> documentation.</div></blockquote>
<p><strong>Module Documentation:</strong></p>
<dl class="class">
<dt id="helpers.continues_statistic">
<em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">continues_statistic</code><span class="sig-paren">(</span><em>mean=None</em>, <em>min_val=None</em>, <em>max_val=None</em>, <em>quantifier=0</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.continues_statistic" title="Permalink to this definition"></a></dt>
<dd><p>This class stores a statistic for a stream of values. The statistic includes: mean, min, max, quantifier.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">You can use the mathematic operators “+, +=” to add a value to the statistic.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>mean</strong> (<em>numeric</em>) – The mean start value, the start value or None.</li>
<li><strong>min_val</strong> (<em>numeric</em>) – The min start value or None</li>
<li><strong>max_val</strong> (<em>numeric</em>) – The max start value or None</li>
<li><strong>quantifier</strong> (<em>int</em>) – The quantifier start value or 0</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>You are able to initialise this class in the following ways:</p>
<ul class="last simple">
<li>Without arguments to get an empty instance</li>
<li>With one single value to get an starting instance</li>
<li>With mean, min_val, max_val, quantifier to initialise an existing statistic</li>
</ul>
</div>
<p><strong>Example:</strong></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
<span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
<span class="kn">import</span> <span class="nn">helpers</span>
<span class="n">cs</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic</span><span class="p">()</span>
<span class="k">for</span> <span class="n">val</span> <span class="ow">in</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">4</span><span class="p">):</span>
<span class="n">cs</span> <span class="o">+=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic</span><span class="p">(</span><span class="n">val</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">cs</span><span class="p">)</span>
</pre></div>
</div>
<p>Will result to the following output:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">mean</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">1</span>
<span class="n">mean</span><span class="o">=</span><span class="mf">2.0</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">2</span>
<span class="n">mean</span><span class="o">=</span><span class="mf">3.0</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">3</span>
<span class="n">mean</span><span class="o">=</span><span class="mf">3.25</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">4</span>
</pre></div>
</div>
<dl class="attribute">
<dt id="helpers.continues_statistic.max">
<code class="descname">max</code><a class="headerlink" href="#helpers.continues_statistic.max" title="Permalink to this definition"></a></dt>
<dd><p>The current max value.</p>
</dd></dl>
<dl class="attribute">
<dt id="helpers.continues_statistic.mean">
<code class="descname">mean</code><a class="headerlink" href="#helpers.continues_statistic.mean" title="Permalink to this definition"></a></dt>
<dd><p>The current mean value.</p>
</dd></dl>
<dl class="attribute">
<dt id="helpers.continues_statistic.min">
<code class="descname">min</code><a class="headerlink" href="#helpers.continues_statistic.min" title="Permalink to this definition"></a></dt>
<dd><p>The current min value.</p>
</dd></dl>
<dl class="method">
<dt id="helpers.continues_statistic.pop">
<code class="descname">pop</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#helpers.continues_statistic.pop" title="Permalink to this definition"></a></dt>
<dd><p>This pops out the current statistic data and returns these as an instance of <a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">The current statistic or None, if no value is available.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a> or None</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="attribute">
<dt id="helpers.continues_statistic.quantifier">
<code class="descname">quantifier</code><a class="headerlink" href="#helpers.continues_statistic.quantifier" title="Permalink to this definition"></a></dt>
<dd><p>The current quantifier (number of values for continues statistic).</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="helpers.continues_statistic_multivalue">
<em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">continues_statistic_multivalue</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.continues_statistic_multivalue" title="Permalink to this definition"></a></dt>
<dd><p>This class stores multiple statistics of stream values. The statistic of each value is stored as <a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">You can use the mathematic operators “+, +=” to add instances.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>You are able to initialise this class in the following ways:</p>
<ul class="last simple">
<li>Without arguments to get an empty instance</li>
<li>With a keword argument(s) which will be passed to <a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">continues_statistic</span></code></a></li>
<li>With a dict equivalent of <a class="reference internal" href="#helpers.continues_statistic_multivalue" title="helpers.continues_statistic_multivalue"><code class="xref py py-class docutils literal notranslate"><span class="pre">continues_statistic_multivalue</span></code></a> to initialise an existing statistic</li>
</ul>
</div>
<p><strong>Example:</strong></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
<span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
<span class="kn">import</span> <span class="nn">helpers</span>
<span class="n">csm</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic_multivalue</span><span class="p">()</span>
<span class="nb">print</span><span class="p">(</span><span class="n">csm</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
<span class="n">csm</span> <span class="o">+=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic_multivalue</span><span class="p">(</span><span class="n">a</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;mean&#39;</span><span class="p">:</span> <span class="mf">3.1</span><span class="p">,</span> <span class="s1">&#39;min_val&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="s1">&#39;max_val&#39;</span><span class="p">:</span> <span class="mf">3.5</span><span class="p">,</span> <span class="s1">&#39;quantifier&#39;</span><span class="p">:</span> <span class="mi">305</span><span class="p">})</span>
<span class="nb">print</span><span class="p">(</span><span class="n">csm</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
<span class="n">csm</span> <span class="o">+=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic_multivalue</span><span class="p">(</span><span class="n">a</span><span class="o">=</span><span class="mf">4.31</span><span class="p">,</span> <span class="n">b</span><span class="o">=</span><span class="p">{</span><span class="s1">&#39;mean&#39;</span><span class="p">:</span> <span class="mf">17.1</span><span class="p">,</span> <span class="s1">&#39;min_val&#39;</span><span class="p">:</span> <span class="mf">13.1</span><span class="p">,</span> <span class="s1">&#39;max_val&#39;</span><span class="p">:</span> <span class="mf">19.3</span><span class="p">,</span> <span class="s1">&#39;quantifier&#39;</span><span class="p">:</span> <span class="mi">27</span><span class="p">})</span>
<span class="nb">print</span><span class="p">(</span><span class="n">csm</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">helpers</span><span class="o">.</span><span class="n">continues_statistic_multivalue</span><span class="p">(</span><span class="nb">dict</span><span class="p">(</span><span class="n">csm</span><span class="p">)),</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;pop out b:&#39;</span><span class="p">,</span> <span class="n">csm</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s1">&#39;b&#39;</span><span class="p">),</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;pop out b:&#39;</span><span class="p">,</span> <span class="n">csm</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s1">&#39;b&#39;</span><span class="p">),</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">csm</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;pop out all:</span><span class="se">\n</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">csm</span><span class="o">.</span><span class="n">pop</span><span class="p">(),</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;pop out all:</span><span class="se">\n</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">csm</span><span class="o">.</span><span class="n">pop</span><span class="p">(),</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">csm</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>Will result to the following output:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">-</span>
<span class="o">--------------------------------------------------------------</span>
<span class="n">a</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">3.1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">3.5</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">305</span>
<span class="o">--------------------------------------------------------------</span>
<span class="n">b</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">17.1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">13.1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">19.3</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">27</span>
<span class="n">a</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">3.103954248366013</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">4.31</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">306</span>
<span class="o">--------------------------------------------------------------</span>
<span class="n">b</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">17.1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">13.1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">19.3</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">27</span>
<span class="n">a</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">3.103954248366013</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">4.31</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">306</span>
<span class="o">--------------------------------------------------------------</span>
<span class="n">pop</span> <span class="n">out</span> <span class="n">b</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">17.1</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mf">13.1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">19.3</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">27</span>
<span class="o">--------------------------------------------------------------</span>
<span class="n">pop</span> <span class="n">out</span> <span class="n">b</span><span class="p">:</span> <span class="kc">None</span>
<span class="o">--------------------------------------------------------------</span>
<span class="n">b</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">0</span>
<span class="n">a</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">3.103954248366013</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">4.31</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">306</span>
<span class="o">--------------------------------------------------------------</span>
<span class="n">pop</span> <span class="n">out</span> <span class="nb">all</span><span class="p">:</span>
<span class="n">b</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">0</span>
<span class="n">a</span><span class="p">:</span> <span class="n">mean</span><span class="o">=</span><span class="mf">3.103954248366013</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mf">4.31</span><span class="p">,</span> <span class="n">quantifier</span><span class="o">=</span><span class="mi">306</span>
<span class="o">--------------------------------------------------------------</span>
<span class="n">pop</span> <span class="n">out</span> <span class="nb">all</span><span class="p">:</span>
<span class="kc">None</span>
<span class="o">--------------------------------------------------------------</span>
<span class="o">-</span>
<span class="o">--------------------------------------------------------------</span>
</pre></div>
</div>
<dl class="method">
<dt id="helpers.continues_statistic_multivalue.pop">
<code class="descname">pop</code><span class="sig-paren">(</span><em>key=None</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.continues_statistic_multivalue.pop" title="Permalink to this definition"></a></dt>
<dd><p>This pops out the current statistic data for a given key and returns these as an instance of <a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a>.</p>
<p>If no key is given it pops out the current statistic data and returns these as an instance of <code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic_multiple</span></code>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>key</strong> (<em>str</em><em> or </em><em>NoneType</em>) – The key to get data for</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The current statistic or None, if no value is available.</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><a class="reference internal" href="#helpers.continues_statistic" title="helpers.continues_statistic"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.continues_statistic</span></code></a> or None</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="helpers.direct_socket_base">
<em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">direct_socket_base</code><span class="sig-paren">(</span><em>max_len=None</em>, <em>virtual_rate_bps=None</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base" title="Permalink to this definition"></a></dt>
<dd><p>This is the base class for other classes in this module.</p>
<dl class="method">
<dt id="helpers.direct_socket_base.disconnect">
<code class="descname">disconnect</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.disconnect" title="Permalink to this definition"></a></dt>
<dd><p>Method to disconnect client and server.</p>
</dd></dl>
<dl class="method">
<dt id="helpers.direct_socket_base.init_channel_name">
<code class="descname">init_channel_name</code><span class="sig-paren">(</span><em>channel_name=None</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.init_channel_name" title="Permalink to this definition"></a></dt>
<dd><p>With this Method, the channel name for logging can be changed.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>channel_name</strong> (<em>str</em>) – The name for the logging channel</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="helpers.direct_socket_base.is_connected">
<code class="descname">is_connected</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.is_connected" title="Permalink to this definition"></a></dt>
<dd><p>With this Method the connection status can be identified.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">True, if a connection is established, otherwise False.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">bool</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="helpers.direct_socket_base.receive">
<code class="descname">receive</code><span class="sig-paren">(</span><em>timeout=1.0</em>, <em>num=None</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.receive" title="Permalink to this definition"></a></dt>
<dd><p>This method returns received data.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>timeout</strong> (<em>float</em>) – The timeout for receiving data (at least after the timeout the method returns data or None).</li>
<li><strong>num</strong> (<em>int</em><em> or </em><em>None</em>) – the number of bytes to receive (use None to get all available data).</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The received data.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bytes</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="helpers.direct_socket_base.register_callback">
<code class="descname">register_callback</code><span class="sig-paren">(</span><em>callback</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.register_callback" title="Permalink to this definition"></a></dt>
<dd><p>This method stores the callback which is executed, if data is available. You need to execute <a class="reference internal" href="#helpers.direct_socket_base.receive" title="helpers.direct_socket_base.receive"><code class="xref py py-func docutils literal notranslate"><span class="pre">receive()</span></code></a> of this instance
given as first argument.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>callback</strong> – The callback which will be executed, when data is available.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="helpers.direct_socket_base.register_connect_callback">
<code class="descname">register_connect_callback</code><span class="sig-paren">(</span><em>callback</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.register_connect_callback" title="Permalink to this definition"></a></dt>
<dd><p>This method stores the callback which is executed, if a connection is established.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>callback</strong> – The callback which will be executed, when a connection is established.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="helpers.direct_socket_base.register_disconnect_callback">
<code class="descname">register_disconnect_callback</code><span class="sig-paren">(</span><em>callback</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.register_disconnect_callback" title="Permalink to this definition"></a></dt>
<dd><p>This method stores the callback which is executed, after the connection is lost.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>callback</strong> – The callback which will be executed, after the connection is lost.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="helpers.direct_socket_base.send">
<code class="descname">send</code><span class="sig-paren">(</span><em>data</em>, <em>timeout=1.0</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_base.send" title="Permalink to this definition"></a></dt>
<dd><p>This method sends data via the initiated communication channel.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>data</strong> (<em>bytes</em>) – The data to be send over the communication channel.</li>
<li><strong>timeout</strong> (<em>float</em>) – The timeout for sending data (e.g. time to establish new connection).</li>
<li><strong>log_lvl</strong> (<em>int</em>) – The log level to log outgoing TX-data</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">True if data had been sent, otherwise False.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">bool</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="helpers.direct_socket_client">
<em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">direct_socket_client</code><span class="sig-paren">(</span><em>max_len=None</em>, <em>virtual_rate_bps=None</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_client" title="Permalink to this definition"></a></dt>
<dd><p>Class to create a direct client socket. See also parent <a class="reference internal" href="#helpers.direct_socket_base" title="helpers.direct_socket_base"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_base</span></code></a>.</p>
<p><strong>Example:</strong></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
<span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
<span class="kn">import</span> <span class="nn">report</span>
<span class="kn">import</span> <span class="nn">helpers</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="k">def</span> <span class="nf">mirror_callback</span><span class="p">(</span><span class="n">sock</span><span class="p">):</span>
<span class="n">sock</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">sock</span><span class="o">.</span><span class="n">receive</span><span class="p">())</span>
<span class="n">report</span><span class="o">.</span><span class="n">stdoutLoggingConfigure</span><span class="p">(</span><span class="n">log_name_lvl</span><span class="o">=</span><span class="p">[(</span><span class="s1">&#39;root&#39;</span><span class="p">,</span> <span class="s1">&#39;DEBUG&#39;</span><span class="p">),</span> <span class="p">])</span>
<span class="n">s</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">direct_socket_server</span><span class="p">(</span><span class="n">virtual_rate_bps</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
<span class="n">s</span><span class="o">.</span><span class="n">init_channel_name</span><span class="p">(</span><span class="s1">&#39;example_server&#39;</span><span class="p">)</span>
<span class="n">s</span><span class="o">.</span><span class="n">register_callback</span><span class="p">(</span><span class="n">mirror_callback</span><span class="p">)</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">direct_socket_client</span><span class="p">(</span><span class="n">max_len</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">virtual_rate_bps</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
<span class="n">c</span><span class="o">.</span><span class="n">init_channel_name</span><span class="p">(</span><span class="s1">&#39;example_client&#39;</span><span class="p">)</span>
<span class="n">c</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
<span class="n">c</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;abc&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;The Client received: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="nb">repr</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">receive</span><span class="p">()))</span>
</pre></div>
</div>
<p>Will result to the following output:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">920</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">RX</span><span class="o">-</span><span class="n">Buffer</span><span class="o">...</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">920</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">Waiting</span> <span class="k">for</span> <span class="n">incomming</span> <span class="n">connection</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">920</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">RX</span><span class="o">-</span><span class="n">Buffer</span><span class="o">...</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">920</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">established</span><span class="o">...</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">921</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">RX</span><span class="o">-</span><span class="n">Buffer</span><span class="o">...</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">921</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">established</span><span class="o">...</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">921</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">RX</span><span class="o">-</span><span class="n">Buffer</span><span class="o">...</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">921</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">321</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">RX</span> <span class="o">&lt;-</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">322</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">322</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">523</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">RX</span> <span class="o">&lt;-</span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">723</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">RX</span> <span class="o">&lt;-</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">723</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
<span class="n">The</span> <span class="n">Client</span> <span class="n">received</span><span class="p">:</span> <span class="sa">b</span><span class="s1">&#39;ab&#39;</span>
</pre></div>
</div>
<dl class="method">
<dt id="helpers.direct_socket_client.connect">
<code class="descname">connect</code><span class="sig-paren">(</span><em>remote_socket</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_client.connect" title="Permalink to this definition"></a></dt>
<dd><p>Method to create a connection between this client and a <a class="reference internal" href="#helpers.direct_socket_server" title="helpers.direct_socket_server"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_server</span></code></a> instance.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>remote_socket</strong> (<a class="reference internal" href="#helpers.direct_socket_server" title="helpers.direct_socket_server"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_server</span></code></a>) – The remote socket to connect to.</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="helpers.direct_socket_client.reconnect">
<code class="descname">reconnect</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_client.reconnect" title="Permalink to this definition"></a></dt>
<dd><p>Method to do a reconnect.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The <code class="xref py py-const docutils literal notranslate"><span class="pre">remote_socket</span></code> of the prefious <a class="reference internal" href="#helpers.direct_socket_client.connect" title="helpers.direct_socket_client.connect"><code class="xref py py-func docutils literal notranslate"><span class="pre">connect()</span></code></a> call will be used.</p>
</div>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="helpers.direct_socket_server">
<em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">direct_socket_server</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.direct_socket_server" title="Permalink to this definition"></a></dt>
<dd><p>Class to create a direct server socket. See also parent <a class="reference internal" href="#helpers.direct_socket_base" title="helpers.direct_socket_base"><code class="xref py py-class docutils literal notranslate"><span class="pre">helpers.direct_socket_base</span></code></a>.</p>
<p><strong>Example:</strong></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
<span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
<span class="kn">import</span> <span class="nn">report</span>
<span class="kn">import</span> <span class="nn">helpers</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="k">def</span> <span class="nf">mirror_callback</span><span class="p">(</span><span class="n">sock</span><span class="p">):</span>
<span class="n">sock</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">sock</span><span class="o">.</span><span class="n">receive</span><span class="p">())</span>
<span class="n">report</span><span class="o">.</span><span class="n">stdoutLoggingConfigure</span><span class="p">(</span><span class="n">log_name_lvl</span><span class="o">=</span><span class="p">[(</span><span class="s1">&#39;root&#39;</span><span class="p">,</span> <span class="s1">&#39;DEBUG&#39;</span><span class="p">),</span> <span class="p">])</span>
<span class="n">s</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">direct_socket_server</span><span class="p">(</span><span class="n">virtual_rate_bps</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
<span class="n">s</span><span class="o">.</span><span class="n">init_channel_name</span><span class="p">(</span><span class="s1">&#39;example_server&#39;</span><span class="p">)</span>
<span class="n">s</span><span class="o">.</span><span class="n">register_callback</span><span class="p">(</span><span class="n">mirror_callback</span><span class="p">)</span>
<span class="n">c</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">direct_socket_client</span><span class="p">(</span><span class="n">max_len</span><span class="o">=</span><span class="mi">2</span><span class="p">,</span> <span class="n">virtual_rate_bps</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
<span class="n">c</span><span class="o">.</span><span class="n">init_channel_name</span><span class="p">(</span><span class="s1">&#39;example_client&#39;</span><span class="p">)</span>
<span class="n">c</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
<span class="n">c</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="sa">b</span><span class="s1">&#39;abc&#39;</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;The Client received: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="nb">repr</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">receive</span><span class="p">()))</span>
</pre></div>
</div>
<p>Will result to the following output:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">920</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">RX</span><span class="o">-</span><span class="n">Buffer</span><span class="o">...</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">920</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">Waiting</span> <span class="k">for</span> <span class="n">incomming</span> <span class="n">connection</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">920</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">all_others</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">RX</span><span class="o">-</span><span class="n">Buffer</span><span class="o">...</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">920</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">established</span><span class="o">...</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">921</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">RX</span><span class="o">-</span><span class="n">Buffer</span><span class="o">...</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">921</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">Connection</span> <span class="n">established</span><span class="o">...</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">921</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">INFO</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">Cleaning</span> <span class="n">RX</span><span class="o">-</span><span class="n">Buffer</span><span class="o">...</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">47</span><span class="p">,</span><span class="mi">921</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">321</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">RX</span> <span class="o">&lt;-</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">322</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">322</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">523</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">RX</span> <span class="o">&lt;-</span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">723</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_client</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Client</span><span class="p">:</span> <span class="n">RX</span> <span class="o">&lt;-</span> <span class="p">(</span><span class="mi">2</span><span class="p">):</span> <span class="mi">61</span> <span class="mi">62</span>
<span class="mi">2021</span><span class="o">-</span><span class="mi">01</span><span class="o">-</span><span class="mi">09</span> <span class="mi">22</span><span class="p">:</span><span class="mi">30</span><span class="p">:</span><span class="mi">48</span><span class="p">,</span><span class="mi">723</span><span class="p">:</span> <span class="n">root</span><span class="o">.</span><span class="n">helpers</span><span class="o">.</span><span class="n">example_server</span> <span class="o">-</span> <span class="n">DEBUG</span> <span class="o">-</span> <span class="n">Server</span><span class="p">:</span> <span class="n">TX</span> <span class="o">-&gt;</span> <span class="p">(</span><span class="mi">1</span><span class="p">):</span> <span class="mi">63</span>
<span class="n">The</span> <span class="n">Client</span> <span class="n">received</span><span class="p">:</span> <span class="sa">b</span><span class="s1">&#39;ab&#39;</span>
</pre></div>
</div>
</dd></dl>
<dl class="class">
<dt id="helpers.ringbuffer">
<em class="property">class </em><code class="descclassname">helpers.</code><code class="descname">ringbuffer</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.ringbuffer" title="Permalink to this definition"></a></dt>
<dd><p>Class for a list with a limited number of elements.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">On adding Objects, the list will be reduced to the maximum length by deleting entries starting from index 0.</p>
</div>
<p><strong>Example:</strong></p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">sys</span>
<span class="n">sys</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s1">&#39;../..&#39;</span><span class="p">)</span>
<span class="kn">import</span> <span class="nn">helpers</span>
<span class="n">rb</span> <span class="o">=</span> <span class="n">helpers</span><span class="o">.</span><span class="n">ringbuffer</span><span class="p">(</span><span class="n">length</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">rb</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
<span class="n">rb</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">rb</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
<span class="n">rb</span><span class="o">.</span><span class="n">extend</span><span class="p">((</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">6</span><span class="p">))</span>
<span class="nb">print</span><span class="p">(</span><span class="n">rb</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
<span class="n">rb</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">17</span><span class="p">)</span>
<span class="nb">print</span><span class="p">(</span><span class="n">rb</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">--------------------------------------------------------------&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>Will result to the following output:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[]</span>
<span class="o">--------------------------------------------------------------</span>
<span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="o">--------------------------------------------------------------</span>
<span class="p">[</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">]</span>
<span class="o">--------------------------------------------------------------</span>
<span class="p">[</span><span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">,</span> <span class="mi">17</span><span class="p">]</span>
<span class="o">--------------------------------------------------------------</span>
</pre></div>
</div>
<dl class="method">
<dt id="helpers.ringbuffer.append">
<code class="descname">append</code><span class="sig-paren">(</span><em>obj</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.ringbuffer.append" title="Permalink to this definition"></a></dt>
<dd><p>Append object to the end of the list.</p>
</dd></dl>
<dl class="method">
<dt id="helpers.ringbuffer.extend">
<code class="descname">extend</code><span class="sig-paren">(</span><em>iterable</em><span class="sig-paren">)</span><a class="headerlink" href="#helpers.ringbuffer.extend" title="Permalink to this definition"></a></dt>
<dd><p>Extend list by appending elements from the iterable.</p>
</dd></dl>
</dd></dl>
</div>
<div class="toctree-wrapper compound">
</div>
</div>
<div class="section" id="indices-and-tables">
<h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline"></a></h1>
<ul class="simple">
<li><a class="reference internal" href="genindex.html"><span class="std std-ref">Index</span></a></li>
<li><a class="reference internal" href="py-modindex.html"><span class="std std-ref">Module Index</span></a></li>
<li><a class="reference internal" href="search.html"><span class="std std-ref">Search Page</span></a></li>
</ul>
</div>
</div>
</div>
<footer>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2021, Dirk Alders
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>