1
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3
<!-- $Id: 10-errors.html,v 2.30.2.5 2009/03/28 11:52:19 irmen Exp $ -->
4
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
5
5
<title>PYRO - Errors and Troubleshooting</title>
6
6
<link rel="stylesheet" type="text/css" href="pyromanual_print.css" media="print">
7
7
<link rel="stylesheet" type="text/css" href="pyromanual.css" media="screen">
29
29
<p>The <a href="#specificissues">Specific issues</a> section at the end contains more detailed discussion of specific issues you may encounter:
31
31
<li>127.0.0.1 connection problems</li>
32
<li>problems when using user defined exception classes</li>
35
35
<h3><a name="errors" id="errors"></a>Pyro Errors</h3>
304
304
<h3><a name="shoot" id="shoot"></a>Troubleshooting</h3>
305
<p><strong>Online Pyro troubleshooting wiki:</strong> I've put up
306
some wiki (interactive) pages about Pyro. One of them is this one: <a href=
307
"http://www.razorvine.net/python/PyroTroubleshooting">Pyro Troubleshooting</a>. Have a look there if you can't find
308
an answer below. (The other pages can be found by going to <a href="http://www.razorvine.net/python/FrontPage">the
310
<p><strong>Using IronPython or Jython?</strong> Each of these has its own possible issues (when compared to standard CPython).
311
If you are using one of these instead of standard CPython, you may experience problems or unexpected behaviour that
312
are not mentioned elsewhere in this chapter or manual.
313
Because both of them are a bit of a moving target, specific issues related to them are
314
discussed on the wiki pages:
315
<a href="http://www.razorvine.net/python/PyroAndJython">Jython</a> ;
316
<a href="http://www.razorvine.net/python/PyroAndIronPython">IronPython</a> .
319
306
<p>Use <code>python -m Pyro.configuration</code> to get a printout of Pyro's active configuration settings.</p>
595
582
<li>Fix your DNS server to return the correct IP address for your host if it returns 127.0.0.1</li>
596
583
<li>Use the appropriate command line options for the Name Server or Event Server script tools to bind it to a different hostname.</li>
586
<h4>Problems with user defined exception classes</h4>
587
<p>In Python 2.5 and later, there is an issue with user-defined exceptions. Say you have a custom exception class written as follows:</p>
588
<pre>class MyEx(Exception):
589
def __init__(self, mymessage):
590
self.mymessage=mymessage
592
return "[MyEx '%s']" % self.mymessage
594
<p>If you are passing these exceptions over the wire in Pyro method calls, you will find that your program crashes with an error like this:</p>
595
<pre>TypeError: ('__init__() takes exactly 2 arguments (1 given)', <class '__main__.MyEx'>, ())</pre>
597
This is not Pyro's fault: it is caused by a change in the Exception classes which was introduced in Python 2.5.
598
This change seems to cause that Exception objects don't follow the usual pickle protocol.
599
The unpickling of the exception object fails, because the <code>__init__</code> method is called without any arguments
600
(it shouldn't even be called at all by the way!).
601
Unfortunately, you won't be able to fix this problem by writing a <code>__getinitargs__</code> or <code>__getnewargs__</code> method to force the correct parameters, because these methods won't be called.
602
The easiest way to work around this problem now seems to change the init method so that it uses <code>*args</code> instead of a single argument (this is what the built in Exceptions seem to do), or change it a little so that it also works with zero arguments:
604
<pre> def __init__(self, mymessage=None):
605
self.mymessage=mymessage
608
If you don't need any special behavior of your own exception objects, it is probably best to just subclass them from Exception and not define any custom methods or properties. That avoids the problem as well. All builtin exceptions should accept a string argument to be used as the exception message, so there is no need to subclass the exception and add custom behavior as shown above, if you just want to remember a message string.
601
612
<div class="nav">