[mod_python] xmlrpclib problem with mod_python

Derek Marshall Derek_Marshall at CBC.ca
Sat May 8 12:02:43 EST 2004


While trying to access an xml-rpc service from a mod_python script using
xmlrpclib the following exception would occur:

    File "/usr/local/lib/python2.3/xmlrpclib.py", line 783, in close raise ResponseError()

The following code worked fine from a Python script, just not within
mod_python:

    proxy = xmlrpclib.ServerProxy("http://myxmlrpcserver")
    response = proxy.myXMLRPCFunction(param)

System Configuration:

    Python 2.3.3
    Apache 1.3.29
    mod_python-2.7.10
    RH-ES2.1 linux

After a lot of painful digging in xmlrpclib I found that the following
work around "resolves" the issue:

hub % diff mp_xmlrpclib.py /usr/local/lib/python2.3/xmlrpclib.py

515d506
<     raise ImportError # XXX - avoiding this import is the work around

Rasing ImportError avoids the following import statement "from
xml.parsers import expat".

After this hack, the ServerProxy object works fine.

I have not tried this with Apache2 and mod_python-3 because that is not
my target environment.

I noticed a few other people were having similar issues and no
workarounds were available so hopefully this helps.

For now I will use a hacked "mp_xmlrpclib.py" script as part of my
package but I would be very interested to know if I was doing something
wrong, if this is a known issue with using mod_python-2 or if there is a
more elegant way to avoid the problem.

Best,

Derek.


More information about the Mod_python mailing list