Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > c3732731228538f6126cae930c10ad71 > files > 186

python-pyro4-4.21-3.mga4.noarch.rpm



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Configuring Pyro &mdash; Pyro 4.21 documentation</title>
    
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '4.21',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </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>
    <link rel="top" title="Pyro 4.21 documentation" href="index.html" />
    <link rel="next" title="Upgrading from Pyro 3" href="upgrading.html" />
    <link rel="prev" title="Tips &amp; Tricks" href="tipstricks.html" /> 
  </head>
  <body>
    <div class="related">
      <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="upgrading.html" title="Upgrading from Pyro 3"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="tipstricks.html" title="Tips &amp; Tricks"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Pyro 4.21 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="configuring-pyro">
<h1>Configuring Pyro<a class="headerlink" href="#configuring-pyro" title="Permalink to this headline">¶</a></h1>
<p>Pyro can be configured using several <em>configuration items</em>.
The current configuration is accessible from the <tt class="docutils literal"><span class="pre">Pyro4.config</span></tt> object, it contains all config items as attributes.
You can read them and update them to change Pyro&#8217;s configuration.
(usually you need to do this at the start of your program).
For instance, to enable message compression and change the server type, you add something like this to the start of your code:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">Pyro4</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">COMPRESSION</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">Pyro4</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">SERVERTYPE</span> <span class="o">=</span> <span class="s">&quot;multiplex&quot;</span>
</pre></div>
</div>
<p>You can also set them outside of your program, using environment variables from the shell.
To avoid conflicts, the environment variables have a <tt class="docutils literal"><span class="pre">PYRO_</span></tt> prefix. This means that if you want
to change the same two settings as above, but by using environment variables, you would do something like:</p>
<div class="highlight-python"><pre>$ export PYRO_COMPRESSION=true
$ export PYRO_SERVERTYPE=multiplex

(or on windows:)
C:\&gt; set PYRO_COMPRESSION=true
C:\&gt; set PYRO_SERVERTYPE=multiplex</pre>
</div>
<div class="section" id="resetting-the-config-to-default-values">
<h2>Resetting the config to default values<a class="headerlink" href="#resetting-the-config-to-default-values" title="Permalink to this headline">¶</a></h2>
<dl class="method">
<dt id="Pyro4.config.reset">
<tt class="descclassname">Pyro4.config.</tt><tt class="descname">reset</tt><big>(</big><span class="optional">[</span><em>useenvironment=True</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#Pyro4.config.reset" title="Permalink to this definition">¶</a></dt>
<dd><p>Resets the configuration items to their builtin default values.
If <cite>useenvironment</cite> is True, it will overwrite builtin config items with any values set
by environment variables. If you don&#8217;t trust your environment, it may be a good idea
to reset the config items to just the builtin defaults (ignoring any environment variables)
by calling this method with <cite>useenvironment</cite> set to False.
Do this before using any other part of the Pyro library.</p>
</dd></dl>

</div>
<div class="section" id="inspecting-current-config">
<h2>Inspecting current config<a class="headerlink" href="#inspecting-current-config" title="Permalink to this headline">¶</a></h2>
<p>To inspect the current configuration you have several options:</p>
<ol class="arabic">
<li><p class="first">Access individual config items: <tt class="docutils literal"><span class="pre">print(Pyro4.config.COMPRESSION)</span></tt></p>
</li>
<li><p class="first">Dump the config in a console window: <strong class="command">python -m Pyro4.configuration</strong>
This will print something like:</p>
<div class="highlight-python"><pre>Pyro version: 4.6
Loaded from: E:\Projects\Pyro4\src\Pyro4
Active configuration settings:
AUTOPROXY = True
COMMTIMEOUT = 0.0
COMPRESSION = False
...</pre>
</div>
</li>
<li><p class="first">Access the config as a dictionary: <tt class="docutils literal"><span class="pre">Pyro4.config.asDict()</span></tt></p>
</li>
<li><p class="first">Access the config string dump (used in #2): <tt class="docutils literal"><span class="pre">Pyro4.config.dump()</span></tt></p>
</li>
</ol>
</div>
<div class="section" id="overview-of-config-items">
<span id="config-items"></span><h2>Overview of Config Items<a class="headerlink" href="#overview-of-config-items" title="Permalink to this headline">¶</a></h2>
<table border="1" class="docutils">
<colgroup>
<col width="11%" />
<col width="3%" />
<col width="7%" />
<col width="79%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">config item</th>
<th class="head">type</th>
<th class="head">default</th>
<th class="head">meaning</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>AUTOPROXY</td>
<td>bool</td>
<td>True</td>
<td>Enable to make Pyro automatically replace Pyro objects by proxies in the method arguments and return values of remote method calls. Doesn&#8217;t work with marshal serializer.</td>
</tr>
<tr class="row-odd"><td>COMMTIMEOUT</td>
<td>float</td>
<td>0.0</td>
<td>network communication timeout in seconds. 0.0=no timeout (infinite wait)</td>
</tr>
<tr class="row-even"><td>COMPRESSION</td>
<td>bool</td>
<td>False</td>
<td>Enable to make Pyro compress the data that travels over the network</td>
</tr>
<tr class="row-odd"><td>DETAILED_TRACEBACK</td>
<td>bool</td>
<td>False</td>
<td>Enable to get detailed exception tracebacks (including the value of local variables per stack frame)</td>
</tr>
<tr class="row-even"><td>DOTTEDNAMES</td>
<td>bool</td>
<td>False</td>
<td>Server side only: Enable to support object traversal using dotted names (a.b.c.d)</td>
</tr>
<tr class="row-odd"><td>HMAC_KEY</td>
<td>bytes</td>
<td>None</td>
<td>Shared secret key to sign all communication messages</td>
</tr>
<tr class="row-even"><td>HOST</td>
<td>str</td>
<td>localhost</td>
<td>Hostname where Pyro daemons will bind on</td>
</tr>
<tr class="row-odd"><td>MAX_MESSAGE_SIZE</td>
<td>int</td>
<td>0</td>
<td>Maximum size in bytes of the messages sent or received on the wire. If a message exceeds this size, a ProtocolError is raised.</td>
</tr>
<tr class="row-even"><td>NS_HOST</td>
<td>str</td>
<td><em>equal to
HOST</em></td>
<td>Hostname for the name server</td>
</tr>
<tr class="row-odd"><td>NS_PORT</td>
<td>int</td>
<td>9090</td>
<td>TCP port of the name server</td>
</tr>
<tr class="row-even"><td>NS_BCPORT</td>
<td>int</td>
<td>9091</td>
<td>UDP port of the broadcast responder from the name server</td>
</tr>
<tr class="row-odd"><td>NS_BCHOST</td>
<td>str</td>
<td>None</td>
<td>Hostname for the broadcast responder of the name sever</td>
</tr>
<tr class="row-even"><td>NATHOST</td>
<td>str</td>
<td>None</td>
<td>External hostname in case of NAT</td>
</tr>
<tr class="row-odd"><td>NATPORT</td>
<td>int</td>
<td>None</td>
<td>External port in case of NAT</td>
</tr>
<tr class="row-even"><td>BROADCAST_ADDRS</td>
<td>str</td>
<td>&lt;broadcast&gt;,
0.0.0.0</td>
<td>List of comma separated addresses that Pyro should send broadcasts to (for NS lookup)</td>
</tr>
<tr class="row-odd"><td>ONEWAY_THREADED</td>
<td>bool</td>
<td>True</td>
<td>Enable to make oneway calls be processed in their own separate thread</td>
</tr>
<tr class="row-even"><td>POLLTIMEOUT</td>
<td>float</td>
<td>2.0</td>
<td>For the multiplexing server only: the timeout of the select or poll calls</td>
</tr>
<tr class="row-odd"><td>SERVERTYPE</td>
<td>str</td>
<td>thread</td>
<td>Select the Pyro server type. thread=thread pool based, multiplex=select/poll based</td>
</tr>
<tr class="row-even"><td>SOCK_REUSE</td>
<td>bool</td>
<td>False</td>
<td>Should SO_REUSEADDR be used on sockets that Pyro creates.</td>
</tr>
<tr class="row-odd"><td>PREFER_IP_VERSION</td>
<td>int</td>
<td>4</td>
<td>The IP address type that is preferred (4=ipv4, 6=ipv6, 0=let OS decide).</td>
</tr>
<tr class="row-even"><td>THREADING2</td>
<td>bool</td>
<td>False</td>
<td>Use the threading2 module if available instead of Python&#8217;s standard threading module</td>
</tr>
<tr class="row-odd"><td>THREADPOOL_MINTHREADS</td>
<td>int</td>
<td>4</td>
<td>For the thread pool server: minimum amount of worker threads to be spawned</td>
</tr>
<tr class="row-even"><td>THREADPOOL_MAXTHREADS</td>
<td>int</td>
<td>50</td>
<td>For the thread pool server: maximum amount of worker threads to be spawned</td>
</tr>
<tr class="row-odd"><td>THREADPOOL_IDLETIMEOUT</td>
<td>float</td>
<td>2.0</td>
<td>For the thread pool server: number of seconds to pass for an idle worker thread to be terminated</td>
</tr>
<tr class="row-even"><td>FLAME_ENABLED</td>
<td>bool</td>
<td>False</td>
<td>Should Pyro Flame be enabled on the server</td>
</tr>
<tr class="row-odd"><td>SERIALIZER</td>
<td>str</td>
<td>serpent</td>
<td>The wire protocol serializer to use (serpent, json, marshal, pickle)</td>
</tr>
<tr class="row-even"><td>LOGWIRE</td>
<td>bool</td>
<td>False</td>
<td>If wire-level message data should be written to the logfile (you may want to disable COMPRESSION)</td>
</tr>
</tbody>
</table>
<p>There are two special config items that are only available as environment variable settings.
This is because they are used at module import time (when the Pyro4 package is being imported).
They control Pyro&#8217;s logging behavior:</p>
<table border="1" class="docutils">
<colgroup>
<col width="10%" />
<col width="3%" />
<col width="6%" />
<col width="80%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">environment variable</th>
<th class="head">type</th>
<th class="head">default</th>
<th class="head">meaning</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td>PYRO_LOGLEVEL</td>
<td>string</td>
<td><em>not set</em></td>
<td>The log level to use for Pyro&#8217;s logger (DEBUG, WARN, ...) See Python&#8217;s standard <tt class="xref py py-mod docutils literal"><span class="pre">logging</span></tt> module for the allowed values. If it is not set, no logging is being configured.</td>
</tr>
<tr class="row-odd"><td>PYRO_LOGFILE</td>
<td>string</td>
<td>pyro.log</td>
<td>The name of the log file. Use {stderr} to make the log go to the standard error output.</td>
</tr>
</tbody>
</table>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="index.html">
              <img class="logo" src="_static/pyro.png" alt="Logo"/>
            </a></p>
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Configuring Pyro</a><ul>
<li><a class="reference internal" href="#resetting-the-config-to-default-values">Resetting the config to default values</a></li>
<li><a class="reference internal" href="#inspecting-current-config">Inspecting current config</a></li>
<li><a class="reference internal" href="#overview-of-config-items">Overview of Config Items</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="tipstricks.html"
                        title="previous chapter">Tips &amp; Tricks</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="upgrading.html"
                        title="next chapter">Upgrading from Pyro 3</a></p>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <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="upgrading.html" title="Upgrading from Pyro 3"
             >next</a> |</li>
        <li class="right" >
          <a href="tipstricks.html" title="Tips &amp; Tricks"
             >previous</a> |</li>
        <li><a href="index.html">Pyro 4.21 documentation</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright Irmen de Jong.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>