mirror of
https://github.com/evennia/evennia.git
synced 2026-03-17 05:16:31 +01:00
486 lines
No EOL
32 KiB
HTML
486 lines
No EOL
32 KiB
HTML
|
||
<!DOCTYPE html>
|
||
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
|
||
|
||
<title>evennia.scripts.tickerhandler — Evennia 3.x documentation</title>
|
||
<link rel="stylesheet" href="../_static/nature.css" type="text/css" />
|
||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||
<script src="../_static/jquery.js"></script>
|
||
<script src="../_static/underscore.js"></script>
|
||
<script src="../_static/doctools.js"></script>
|
||
<script src="../_static/language_data.js"></script>
|
||
<link rel="shortcut icon" href="../_static/favicon.ico"/>
|
||
<link rel="index" title="Index" href="../genindex.html" />
|
||
<link rel="search" title="Search" href="../search.html" />
|
||
<link rel="next" title="evennia.server" href="evennia.server.html" />
|
||
<link rel="prev" title="evennia.scripts.taskhandler" href="evennia.scripts.taskhandler.html" />
|
||
</head><body>
|
||
|
||
|
||
<div class="admonition important">
|
||
<p class="first admonition-title">Note</p>
|
||
<p class="last">You are reading an old version of the Evennia documentation. <a href="https://www.evennia.com/docs/latest/index.html">The latest version is here</a></p>.
|
||
</div>
|
||
|
||
|
||
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
accesskey="I">index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.server.html" title="evennia.server"
|
||
accesskey="N">next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.scripts.taskhandler.html" title="evennia.scripts.taskhandler"
|
||
accesskey="P">previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 3.x</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-4"><a href="evennia.scripts.html" accesskey="U">evennia.scripts</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.scripts.tickerhandler</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div class="document">
|
||
|
||
<div class="documentwrapper">
|
||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||
<div class="sphinxsidebarwrapper">
|
||
<p class="logo"><a href="../index.html">
|
||
<img class="logo" src="../_static/evennia_logo.png" alt="Logo"/>
|
||
</a></p>
|
||
<div id="searchbox" style="display: none" role="search">
|
||
<h3 id="searchlabel">Quick search</h3>
|
||
<div class="searchformwrapper">
|
||
<form class="search" action="../search.html" method="get">
|
||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||
<input type="submit" value="Go" />
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<script>$('#searchbox').show(0);</script>
|
||
<h4>Previous topic</h4>
|
||
<p class="topless"><a href="evennia.scripts.taskhandler.html"
|
||
title="previous chapter">evennia.scripts.taskhandler</a></p>
|
||
<h4>Next topic</h4>
|
||
<p class="topless"><a href="evennia.server.html"
|
||
title="next chapter">evennia.server</a></p>
|
||
<div role="note" aria-label="source link">
|
||
<!--h3>This Page</h3-->
|
||
<ul class="this-page-menu">
|
||
<li><a href="../_sources/api/evennia.scripts.tickerhandler.md.txt"
|
||
rel="nofollow">Show Page Source</a></li>
|
||
</ul>
|
||
</div><h3>Links</h3>
|
||
<ul>
|
||
<li><a href="https://www.evennia.com/docs/latest/index.html">Documentation Top</a> </li>
|
||
<li><a href="https://www.evennia.com">Evennia Home</a> </li>
|
||
<li><a href="https://github.com/evennia/evennia">Github</a> </li>
|
||
<li><a href="http://games.evennia.com">Game Index</a> </li>
|
||
<li>
|
||
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
|
||
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
|
||
<a href="https://evennia.blogspot.com/">Blog</a>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
<div class="bodywrapper">
|
||
<div class="body" role="main">
|
||
|
||
<section id="module-evennia.scripts.tickerhandler">
|
||
<span id="evennia-scripts-tickerhandler"></span><h1>evennia.scripts.tickerhandler<a class="headerlink" href="#module-evennia.scripts.tickerhandler" title="Permalink to this headline">¶</a></h1>
|
||
<p>TickerHandler</p>
|
||
<p>This implements an efficient Ticker which uses a subscription
|
||
model to ‘tick’ subscribed objects at regular intervals.</p>
|
||
<p>The ticker mechanism is used by importing and accessing
|
||
the instantiated TICKER_HANDLER instance in this module. This
|
||
instance is run by the server; it will save its status across
|
||
server reloads and be started automaticall on boot.</p>
|
||
<p>Example:</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">evennia.scripts.tickerhandler</span> <span class="kn">import</span> <span class="n">TICKER_HANDLER</span>
|
||
|
||
<span class="c1"># call tick myobj.at_tick(*args, **kwargs) every 15 seconds</span>
|
||
<span class="n">TICKER_HANDLER</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="mi">15</span><span class="p">,</span> <span class="n">myobj</span><span class="o">.</span><span class="n">at_tick</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>You supply the interval to tick and a callable to call regularly with
|
||
any extra args/kwargs. The callable should either be a stand-alone
|
||
function in a module <em>or</em> the method on a <em>typeclassed</em> entity (that
|
||
is, on an object that can be safely and stably returned from the
|
||
database). Functions that are dynamically created or sits on
|
||
in-memory objects cannot be used by the tickerhandler (there is no way
|
||
to reference them safely across reboots and saves).</p>
|
||
<p>The handler will transparently set
|
||
up and add new timers behind the scenes to tick at given intervals,
|
||
using a TickerPool - all callables with the same interval will share
|
||
the interval ticker.</p>
|
||
<p>To remove:</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">TICKER_HANDLER</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="mi">15</span><span class="p">,</span> <span class="n">myobj</span><span class="o">.</span><span class="n">at_tick</span><span class="p">)</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>Both interval and callable must be given since a single object can be subscribed
|
||
to many different tickers at the same time. You can also supply <strong>idstring</strong>
|
||
as an identifying string if you ever want to tick the callable at the same interval
|
||
but with different arguments (args/kwargs are not used for identifying the ticker). There
|
||
is also <strong>persistent=False</strong> if you don’t want to make a ticker that don’t survive a reload.
|
||
If either or both <strong>idstring</strong> or <strong>persistent</strong> has been changed from their defaults, they
|
||
must be supplied to the <strong>TICKER_HANDLER.remove</strong> call to properly identify the ticker
|
||
to remove.</p>
|
||
<p>The TickerHandler’s functionality can be overloaded by modifying the
|
||
Ticker class and then changing TickerPool and TickerHandler to use the
|
||
custom classes</p>
|
||
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">MyTicker</span><span class="p">(</span><span class="n">Ticker</span><span class="p">):</span>
|
||
<span class="c1"># [doing custom stuff]</span>
|
||
|
||
<span class="k">class</span> <span class="nc">MyTickerPool</span><span class="p">(</span><span class="n">TickerPool</span><span class="p">):</span>
|
||
<span class="n">ticker_class</span> <span class="o">=</span> <span class="n">MyTicker</span>
|
||
<span class="k">class</span> <span class="nc">MyTickerHandler</span><span class="p">(</span><span class="n">TickerHandler</span><span class="p">):</span>
|
||
<span class="n">ticker_pool_class</span> <span class="o">=</span> <span class="n">MyTickerPool</span>
|
||
</pre></div>
|
||
</div>
|
||
<p>If one wants to duplicate TICKER_HANDLER’s auto-saving feature in
|
||
a custom handler one can make a custom <strong>AT_STARTSTOP_MODULE</strong> entry to
|
||
call the handler’s <strong>save()</strong> and <strong>restore()</strong> methods when the server reboots.</p>
|
||
<dl class="py class">
|
||
<dt id="evennia.scripts.tickerhandler.Ticker">
|
||
<em class="property">class </em><code class="sig-prename descclassname">evennia.scripts.tickerhandler.</code><code class="sig-name descname">Ticker</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">interval</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#Ticker"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.Ticker" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
|
||
<p>Represents a repeatedly running task that calls
|
||
hooks repeatedly. Overload <strong>_callback</strong> to change the
|
||
way it operates.</p>
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.Ticker.__init__">
|
||
<code class="sig-name descname">__init__</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">interval</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#Ticker.__init__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.Ticker.__init__" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Set up the ticker</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>interval</strong> (<em>int</em>) – The stepping interval.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.Ticker.validate">
|
||
<code class="sig-name descname">validate</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">start_delay</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#Ticker.validate"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.Ticker.validate" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Start/stop the task depending on how many subscribers we have
|
||
using it.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>start_delay</strong> (<em>int</em><em>, </em><em>optional</em>) – Time to way before starting.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.Ticker.add">
|
||
<code class="sig-name descname">add</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">store_key</span></em>, <em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#Ticker.add"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.Ticker.add" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Sign up a subscriber to this ticker.
|
||
:param store_key: Unique storage hash for this ticker subscription.
|
||
:type store_key: str
|
||
:param args: Arguments to call the hook method with.
|
||
:type args: any, optional</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Keyword Arguments</dt>
|
||
<dd class="field-odd"><p><strong>_start_delay</strong> (<em>int</em>) – If set, this will be
|
||
used to delay the start of the trigger instead of
|
||
<strong>interval</strong>.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.Ticker.remove">
|
||
<code class="sig-name descname">remove</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">store_key</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#Ticker.remove"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.Ticker.remove" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Unsubscribe object from this ticker</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>store_key</strong> (<em>str</em>) – Unique store key.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.Ticker.stop">
|
||
<code class="sig-name descname">stop</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#Ticker.stop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.Ticker.stop" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Kill the Task, regardless of subscriptions.</p>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
<dl class="py class">
|
||
<dt id="evennia.scripts.tickerhandler.TickerPool">
|
||
<em class="property">class </em><code class="sig-prename descclassname">evennia.scripts.tickerhandler.</code><code class="sig-name descname">TickerPool</code><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#TickerPool"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.TickerPool" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
|
||
<p>This maintains a pool of
|
||
<strong>evennia.scripts.scripts.ExtendedLoopingCall</strong> tasks for calling
|
||
subscribed objects at given times.</p>
|
||
<dl class="py attribute">
|
||
<dt id="evennia.scripts.tickerhandler.TickerPool.ticker_class">
|
||
<code class="sig-name descname">ticker_class</code><a class="headerlink" href="#evennia.scripts.tickerhandler.TickerPool.ticker_class" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>alias of <a class="reference internal" href="#evennia.scripts.tickerhandler.Ticker" title="evennia.scripts.tickerhandler.Ticker"><code class="xref py py-class docutils literal notranslate"><span class="pre">Ticker</span></code></a></p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.TickerPool.__init__">
|
||
<code class="sig-name descname">__init__</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#TickerPool.__init__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.TickerPool.__init__" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Initialize the pool.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.TickerPool.add">
|
||
<code class="sig-name descname">add</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">store_key</span></em>, <em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#TickerPool.add"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.TickerPool.add" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Add new ticker subscriber.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>store_key</strong> (<em>str</em>) – Unique storage hash.</p></li>
|
||
<li><p><strong>args</strong> (<em>any</em><em>, </em><em>optional</em>) – Arguments to send to the hook method.</p></li>
|
||
</ul>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.TickerPool.remove">
|
||
<code class="sig-name descname">remove</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">store_key</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#TickerPool.remove"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.TickerPool.remove" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Remove subscription from pool.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>store_key</strong> (<em>str</em>) – Unique storage hash to remove</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.TickerPool.stop">
|
||
<code class="sig-name descname">stop</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">interval</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#TickerPool.stop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.TickerPool.stop" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Stop all scripts in pool. This is done at server reload since
|
||
restoring the pool will automatically re-populate the pool.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>interval</strong> (<em>int</em><em>, </em><em>optional</em>) – Only stop tickers with this interval.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
<dl class="py class">
|
||
<dt id="evennia.scripts.tickerhandler.TickerHandler">
|
||
<em class="property">class </em><code class="sig-prename descclassname">evennia.scripts.tickerhandler.</code><code class="sig-name descname">TickerHandler</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">save_name</span><span class="o">=</span><span class="default_value">'ticker_storage'</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#TickerHandler"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.TickerHandler" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
|
||
<p>The Tickerhandler maintains a pool of tasks for subscribing
|
||
objects to various tick rates. The pool maintains creation
|
||
instructions and and re-applies them at a server restart.</p>
|
||
<dl class="py attribute">
|
||
<dt id="evennia.scripts.tickerhandler.TickerHandler.ticker_pool_class">
|
||
<code class="sig-name descname">ticker_pool_class</code><a class="headerlink" href="#evennia.scripts.tickerhandler.TickerHandler.ticker_pool_class" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>alias of <a class="reference internal" href="#evennia.scripts.tickerhandler.TickerPool" title="evennia.scripts.tickerhandler.TickerPool"><code class="xref py py-class docutils literal notranslate"><span class="pre">TickerPool</span></code></a></p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.TickerHandler.__init__">
|
||
<code class="sig-name descname">__init__</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">save_name</span><span class="o">=</span><span class="default_value">'ticker_storage'</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#TickerHandler.__init__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.TickerHandler.__init__" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Initialize handler</p>
|
||
<dl class="simple">
|
||
<dt>save_name (str, optional): The name of the ServerConfig</dt><dd><p>instance to store the handler state persistently.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.TickerHandler.save">
|
||
<code class="sig-name descname">save</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#TickerHandler.save"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.TickerHandler.save" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Save ticker_storage as a serialized string into a temporary
|
||
ServerConf field. Whereas saving is done on the fly, if called
|
||
by server when it shuts down, the current timer of each ticker
|
||
will be saved so it can start over from that point.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.TickerHandler.restore">
|
||
<code class="sig-name descname">restore</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">server_reload</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#TickerHandler.restore"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.TickerHandler.restore" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Restore ticker_storage from database and re-initialize the
|
||
handler from storage. This is triggered by the server at
|
||
restart.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>server_reload</strong> (<em>bool</em><em>, </em><em>optional</em>) – If this is False, it means
|
||
the server went through a cold reboot and all
|
||
non-persistent tickers must be killed.</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.TickerHandler.add">
|
||
<code class="sig-name descname">add</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">interval</span><span class="o">=</span><span class="default_value">60</span></em>, <em class="sig-param"><span class="n">callback</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">idstring</span><span class="o">=</span><span class="default_value">''</span></em>, <em class="sig-param"><span class="n">persistent</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#TickerHandler.add"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.TickerHandler.add" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Add subscription to tickerhandler</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>*args</strong> – Will be passed into the callback every time it’s called. This must be
|
||
data possible to pickle.</p>
|
||
</dd>
|
||
<dt class="field-even">Keyword Arguments</dt>
|
||
<dd class="field-even"><ul class="simple">
|
||
<li><p><strong>interval</strong> (<em>int</em>) – Interval in seconds between calling
|
||
<strong>callable(*args, **kwargs)</strong></p></li>
|
||
<li><p><strong>callable</strong> (<em>callable function</em><em> or </em><em>method</em>) – This
|
||
should either be a stand-alone function or a method on a
|
||
typeclassed entity (that is, one that can be saved to the
|
||
database).</p></li>
|
||
<li><p><strong>idstring</strong> (<em>str</em>) – Identifier for separating
|
||
this ticker-subscription from others with the same
|
||
interval. Allows for managing multiple calls with
|
||
the same time interval and callback.</p></li>
|
||
<li><p><strong>persistent</strong> (<em>bool</em>) – A ticker will always survive
|
||
a server reload. If this is unset, the ticker will be
|
||
deleted by a server shutdown.</p></li>
|
||
<li><p><strong>Will be passed into the callback every time it is called.</strong> (<em>**kwargs</em>) – This must be data possible to pickle.</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p><p><em>store_key (tuple)</em> –</p>
|
||
<dl class="simple">
|
||
<dt>The immutable store-key for this ticker. This can</dt><dd><p>be stored and passed into <strong>.remove(store_key=store_key)</strong> later to
|
||
easily stop this ticker later.</p>
|
||
</dd>
|
||
</dl>
|
||
</p>
|
||
</dd>
|
||
</dl>
|
||
<p class="rubric">Notes</p>
|
||
<p>The callback will be identified by type and stored either as
|
||
as combination of serialized database object + methodname or
|
||
as a python-path to the module + funcname. These strings will
|
||
be combined iwth <strong>interval</strong> and <strong>idstring</strong> to define a
|
||
unique storage key for saving. These must thus all be supplied
|
||
when wanting to modify/remove the ticker later.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.TickerHandler.remove">
|
||
<code class="sig-name descname">remove</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">interval</span><span class="o">=</span><span class="default_value">60</span></em>, <em class="sig-param"><span class="n">callback</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">idstring</span><span class="o">=</span><span class="default_value">''</span></em>, <em class="sig-param"><span class="n">persistent</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">store_key</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#TickerHandler.remove"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.TickerHandler.remove" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Remove ticker subscription from handler.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Keyword Arguments</dt>
|
||
<dd class="field-odd"><ul class="simple">
|
||
<li><p><strong>interval</strong> (<em>int</em>) – Interval of ticker to remove.</p></li>
|
||
<li><p><strong>callback</strong> (<em>callable function</em><em> or </em><em>method</em>) – Either a function or
|
||
the method of a typeclassed object.</p></li>
|
||
<li><p><strong>idstring</strong> (<em>str</em>) – Identifier id of ticker to remove.</p></li>
|
||
<li><p><strong>persistent</strong> (<em>bool</em>) – Whether this ticker is persistent or not.</p></li>
|
||
<li><p><strong>store_key</strong> (<em>str</em>) – If given, all other kwargs are ignored and only
|
||
this is used to identify the ticker.</p></li>
|
||
</ul>
|
||
</dd>
|
||
<dt class="field-even">Raises</dt>
|
||
<dd class="field-even"><p><strong>KeyError</strong> – If no matching ticker was found to remove.</p>
|
||
</dd>
|
||
</dl>
|
||
<p class="rubric">Notes</p>
|
||
<p>The store-key is normally built from the interval/callback/idstring/persistent values;
|
||
but if the <strong>store_key</strong> is explicitly given, this is used instead.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.TickerHandler.clear">
|
||
<code class="sig-name descname">clear</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">interval</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#TickerHandler.clear"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.TickerHandler.clear" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Stop/remove tickers from handler.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>interval</strong> (<em>int</em><em>, </em><em>optional</em>) – Only stop tickers with this interval.</p>
|
||
</dd>
|
||
</dl>
|
||
<p class="rubric">Notes</p>
|
||
<p>This is the only supported way to kill tickers related to
|
||
non-db objects.</p>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.TickerHandler.all">
|
||
<code class="sig-name descname">all</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">interval</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#TickerHandler.all"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.TickerHandler.all" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Get all ticker subscriptions.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Parameters</dt>
|
||
<dd class="field-odd"><p><strong>interval</strong> (<em>int</em><em>, </em><em>optional</em>) – Limit match to tickers with this interval.</p>
|
||
</dd>
|
||
<dt class="field-even">Returns</dt>
|
||
<dd class="field-even"><p><em>list or dict</em> – If <strong>interval</strong> was given, this is a list of tickers using that interval.
|
||
If <strong>interval</strong> was <em>not</em> given, this is a dict
|
||
<strong>{interval1: [ticker1, ticker2, …], …}</strong></p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
<dl class="py method">
|
||
<dt id="evennia.scripts.tickerhandler.TickerHandler.all_display">
|
||
<code class="sig-name descname">all_display</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/scripts/tickerhandler.html#TickerHandler.all_display"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.scripts.tickerhandler.TickerHandler.all_display" title="Permalink to this definition">¶</a></dt>
|
||
<dd><p>Get all tickers on an easily displayable form.</p>
|
||
<dl class="field-list simple">
|
||
<dt class="field-odd">Returns</dt>
|
||
<dd class="field-odd"><p><em>tickers (dict)</em> – A list of all storekeys</p>
|
||
</dd>
|
||
</dl>
|
||
</dd></dl>
|
||
|
||
</dd></dl>
|
||
|
||
</section>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
<div class="related" role="navigation" aria-label="related navigation">
|
||
<h3>Navigation</h3>
|
||
<ul>
|
||
<li class="right" style="margin-right: 10px">
|
||
<a href="../genindex.html" title="General Index"
|
||
>index</a></li>
|
||
<li class="right" >
|
||
<a href="../py-modindex.html" title="Python Module Index"
|
||
>modules</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.server.html" title="evennia.server"
|
||
>next</a> |</li>
|
||
<li class="right" >
|
||
<a href="evennia.scripts.taskhandler.html" title="evennia.scripts.taskhandler"
|
||
>previous</a> |</li>
|
||
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 3.x</a> »</li>
|
||
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> »</li>
|
||
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> »</li>
|
||
<li class="nav-item nav-item-4"><a href="evennia.scripts.html" >evennia.scripts</a> »</li>
|
||
<li class="nav-item nav-item-this"><a href="">evennia.scripts.tickerhandler</a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
|
||
<div class="admonition important">
|
||
<p class="first admonition-title">Note</p>
|
||
<p class="last">You are reading an old version of the Evennia documentation. <a href="https://www.evennia.com/docs/latest/index.html">The latest version is here</a></p>.
|
||
</div>
|
||
|
||
|
||
<div class="footer" role="contentinfo">
|
||
© Copyright 2023, The Evennia developer community.
|
||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
|
||
</div>
|
||
</body>
|
||
</html> |