mirror of
https://github.com/evennia/evennia.git
synced 2026-03-25 09:16:32 +01:00
Updated HTML docs
This commit is contained in:
parent
f505351730
commit
a551188691
1002 changed files with 30387 additions and 9820 deletions
|
|
@ -7,11 +7,13 @@
|
|||
<title>Async Process — Evennia 1.0-dev 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" />
|
||||
|
|
@ -25,7 +27,10 @@
|
|||
<li class="right" >
|
||||
<a href="py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="index.html">Evennia 1.0-dev documentation</a> »</li>
|
||||
<li class="nav-item nav-item-0"><a href="index.html">Evennia 1.0-dev documentation</a> »</li>
|
||||
<li class="nav-item nav-item-last"><a href="#">Async Process</a></li>
|
||||
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
|
@ -102,7 +107,8 @@ above) finishes successfully. The argument <code class="docutils literal notrans
|
|||
</pre></div>
|
||||
</td></tr></table></div>
|
||||
</li>
|
||||
<li><p><code class="docutils literal notranslate"><span class="pre">at_return_kwargs</span></code> - an optional dictionary that will be fed as keyword arguments to the <code class="docutils literal notranslate"><span class="pre">at_return</span></code> callback.</p></li>
|
||||
<li><p><code class="docutils literal notranslate"><span class="pre">at_return_kwargs</span></code> - an optional dictionary that will be fed as keyword arguments to the
|
||||
<code class="docutils literal notranslate"><span class="pre">at_return</span></code> callback.</p></li>
|
||||
<li><p><code class="docutils literal notranslate"><span class="pre">at_err(e)</span></code> (the <em>errback</em>) is called if the asynchronous function fails and raises an exception.
|
||||
This exception is passed to the errback wrapped in a <em>Failure</em> object <code class="docutils literal notranslate"><span class="pre">e</span></code>. If you do not supply an
|
||||
errback of your own, Evennia will automatically add one that silently writes errors to the evennia
|
||||
|
|
@ -137,7 +143,8 @@ errback.</p></li>
|
|||
17
|
||||
18
|
||||
19
|
||||
20</pre></div></td><td class="code"><div class="highlight"><pre><span></span> <span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">utils</span><span class="p">,</span> <span class="n">Command</span>
|
||||
20
|
||||
21</pre></div></td><td class="code"><div class="highlight"><pre><span></span> <span class="kn">from</span> <span class="nn">evennia</span> <span class="kn">import</span> <span class="n">utils</span><span class="p">,</span> <span class="n">Command</span>
|
||||
|
||||
<span class="k">class</span> <span class="nc">CmdAsync</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
|
||||
|
||||
|
|
@ -156,11 +163,13 @@ errback.</p></li>
|
|||
<span class="bp">self</span><span class="o">.</span><span class="n">caller</span><span class="o">.</span><span class="n">msg</span><span class="p">(</span><span class="s2">"There was an error: </span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">e</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># do the async call, setting all callbacks</span>
|
||||
<span class="n">utils</span><span class="o">.</span><span class="n">run_async</span><span class="p">(</span><span class="n">long_running_function</span><span class="p">,</span> <span class="n">at_return</span><span class="o">=</span><span class="n">at_return_function</span><span class="p">,</span> <span class="n">at_err</span><span class="o">=</span><span class="n">at_err_function</span><span class="p">)</span>
|
||||
<span class="n">utils</span><span class="o">.</span><span class="n">run_async</span><span class="p">(</span><span class="n">long_running_function</span><span class="p">,</span> <span class="n">at_return</span><span class="o">=</span><span class="n">at_return_function</span><span class="p">,</span>
|
||||
<span class="n">at_err</span><span class="o">=</span><span class="n">at_err_function</span><span class="p">)</span>
|
||||
</pre></div>
|
||||
</td></tr></table></div>
|
||||
<p>That’s it - from here on we can forget about <code class="docutils literal notranslate"><span class="pre">long_running_function</span></code> and go on with what else need
|
||||
to be done. <em>Whenever</em> it finishes, the <code class="docutils literal notranslate"><span class="pre">at_return_function</span></code> function will be called and the final value will
|
||||
to be done. <em>Whenever</em> it finishes, the <code class="docutils literal notranslate"><span class="pre">at_return_function</span></code> function will be called and the final
|
||||
value will
|
||||
pop up for us to see. If not we will see an error message.</p>
|
||||
</div>
|
||||
<div class="section" id="delay">
|
||||
|
|
@ -194,7 +203,8 @@ the <a class="reference internal" href="Command-Duration.html"><span class="doc"
|
|||
</div>
|
||||
<div class="section" id="the-interactive-decorator">
|
||||
<h2>The @interactive decorator<a class="headerlink" href="#the-interactive-decorator" title="Permalink to this headline">¶</a></h2>
|
||||
<p>As of Evennia 0.9, the <code class="docutils literal notranslate"><span class="pre">@interactive</span></code> <a class="reference external" href="https://realpython.com/primer-on-python-decorators/">decorator</a>
|
||||
<p>As of Evennia 0.9, the <code class="docutils literal notranslate"><span class="pre">@interactive</span></code> [decorator](https://realpython.com/primer-on-python-
|
||||
decorators/)
|
||||
is available. This makes any function or method possible to ‘pause’ and/or await player input
|
||||
in an interactive way.</p>
|
||||
<div class="highlight-python notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
|
||||
|
|
@ -282,7 +292,8 @@ expected, but they may appear with delays or in groups.</p>
|
|||
<div class="section" id="further-reading">
|
||||
<h2>Further reading<a class="headerlink" href="#further-reading" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Technically, <code class="docutils literal notranslate"><span class="pre">run_async</span></code> is just a very thin and simplified wrapper around a
|
||||
<a class="reference external" href="http://twistedmatrix.com/documents/9.0.0/core/howto/defer.html">Twisted Deferred</a> object; the wrapper sets
|
||||
<a class="reference external" href="http://twistedmatrix.com/documents/9.0.0/core/howto/defer.html">Twisted Deferred</a> object; the
|
||||
wrapper sets
|
||||
up a default errback also if none is supplied. If you know what you are doing there is nothing
|
||||
stopping you from bypassing the utility function, building a more sophisticated callback chain after
|
||||
your own liking.</p>
|
||||
|
|
@ -347,7 +358,10 @@ your own liking.</p>
|
|||
<li class="right" >
|
||||
<a href="py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="index.html">Evennia 1.0-dev documentation</a> »</li>
|
||||
<li class="nav-item nav-item-0"><a href="index.html">Evennia 1.0-dev documentation</a> »</li>
|
||||
<li class="nav-item nav-item-last"><a href="#">Async Process</a></li>
|
||||
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue