473,598 Members | 2,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting full exception information from an xmlrpc server

I'm debugging an xmlrpc client/server application. Often when an
exception occurs in the server, I receive only a very short error
message on the client. For example:

xmlrpclib.Fault : <Fault 1: "<type 'exceptions.Ass ertionError'>:" >

Presumably this is because xmlrpclib on the server is catching the
exception, and only sending the exception name to the client, not the
server's stack trace.

What I would like is the full stack trace of what went wrong on the
server (i.e. the junk python usually dumps to the console when an
exception occurs). I don't care which side I see the dump on (client
or server), but I need to see the whole trace so I can figure out what
the problem is. Is there an easy way to do this?

Thanks,
Scott
Aug 13 '08 #1
2 4594
Scott wrote:
I'm debugging an xmlrpc client/server application. Often when an
exception occurs in the server, I receive only a very short error
message on the client. For example:

xmlrpclib.Fault : <Fault 1: "<type 'exceptions.Ass ertionError'>:" >

Presumably this is because xmlrpclib on the server is catching the
exception, and only sending the exception name to the client, not the
server's stack trace.
xmlrpclib is a client library. The faultString message you see here is
provided by the server.

</F>

Aug 13 '08 #2
On Aug 13, 3:31 pm, Scott <smba...@gmail. comwrote:
What I would like is the full stack trace of what went wrong on the
server (i.e. the junk python usually dumps to the console when an
exception occurs). I don't care which side I see the dump on (client
or server), but I need to see the whole trace so I can figure out what
the problem is. Is there an easy way to do this?
I had the same need and I am copying the code I used here. Please note
that the code does a little bit more than getting the full stack
traces. To use it, simply copy it to a file and use "Server" and
"ServerProx y" from this module.

Thanks,
Raghu

---

'''

This package provides a userful wrapper around the xmlrpc client and
server
from stdlib. The main benefits include:

The server provides functions alive and kill. More over, any exception
generated
in rpc functions result in the whole stack trace to be sent across.
The client
processes this stack trace and re-raises the exception.

'''

from SimpleXMLRPCSer ver import SimpleXMLRPCSer ver
import xmlrpclib
import sys
import socket
import SocketServer
import traceback

# All public methods in this class are callable by clients.
class UtilityFuncs(ob ject):
def __init__(self, *args, **kwargs):
self.running = True

def kill(self):
self.running = False
return True

def alive(self):
return True

class Server(SimpleXM LRPCServer):
def __init__(self, *args, **kwargs):
self.util_inst = UtilityFuncs()
SimpleXMLRPCSer ver.__init__(se lf, *args, **kwargs)
self.register_i nstance(self.ut il_inst)

def server_bind(sel f):
self.socket.set sockopt(socket. SOL_SOCKET, socket.SO_REUSE ADDR,
1)
SimpleXMLRPCSer ver.server_bind (self)

# The default dispatcher does not send across the whole stack
trace.
# Only type and value are passed back. The client has no way of
knowing
# the exact place where error occurred in the server (short of
some
# other means such as server logging). This dispatcher sends the
whole
# stack trace.
def _dispatch(self, method, params):
try:
return SimpleXMLRPCSer ver._dispatch(s elf, method, params)
except:
# can't use format_exc() as it is not available in jython
yet (even
# in trunk).
type, value, tb = sys.exc_info()
raise xmlrpclib.Fault (1,
''.join(traceba ck.format_excep tion(type, value, tb)))

def serve_until_don e(self):
# In a threaded server, kill() may need to be called twice.
The first,
# time it is called, the loop may test 'running' before the
new thread
# has a chance to set it to False.
while self.util_inst. running:
self.handle_req uest()

class ThreadedServer( SocketServer.Th readingMixIn, Server):
pass

# A special exception has been defined just to indicate in the client
that the exception
# has in fact originated on the server.
class ServerException (Exception):
pass

# The server sends the whole stack trace as a string. Convert it back
to
# an exception here.
class ExceptionUnmars haller(xmlrpcli b.Unmarshaller) :
def close(self):
try:
return xmlrpclib.Unmar shaller.close(s elf)
except xmlrpclib.Fault , e:
raise ServerException (e.faultString)

class ExceptionTransp ort(xmlrpclib.T ransport):
# getparser() in xmlrpclib.Trans port has logic to choose fastest
parser
# available. The parser needs to be passed an unmarshaller.
Unfortunately,
# getparser() there does not take unmarshaller as a parameter so
we
# can not simply call it with our unmarshaller. Either the whole
code
# there needs to be replicated here using our unmarshaller or we
use
# a much simpler version. The latter is chosen (partly because the
code is
# inspired by ASPN recipe 365244.
def getparser(self) :
unmarshaller = ExceptionUnmars haller()
parser = xmlrpclib.Expat Parser(unmarsha ller)
return parser, unmarshaller

class ServerProxy(xml rpclib.ServerPr oxy):
def __init__ (self, *args, **kwargs):
# Supply our own transport
try:
kwargs['transport']
except:
# This is expected
pass
else:
raise Exception('A transport (%s) is provided. This is not
expected as '
'a custom transport is being used' %
kwargs['transport'])

kwargs['transport'] = ExceptionTransp ort()
xmlrpclib.Serve rProxy.__init__ (self, *args, **kwargs)
---
Aug 13 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1827
by: glin | last post by:
Hi I am trying to integrate the xmlrpc server into a class, does anyone know how to get it working? test.html: <html> <head> <title>XMLRPC Test</title> <script src="jsolait/init.js"></script> <script src="jsolait/lib/urllib.js"></script> <script src="jsolait/lib/xml.js"></script>
0
1727
by: Juan Carlos CORUÑA | last post by:
Hello all, I'm trying to create a COM Server with an embedded xmlrpc server. Here is way it must work: - The client application (programmed with a COM capable language) instantiates my COM server (programmed with python). - The COM server must have a connect interface in order to let the client application process the xmlrpc request. - After executing a "serveforever" method on the COM server it begins
1
2789
by: Joxean Koret | last post by:
Hi to all! I'm having troubles to make my XMLRPC application working with non ASCII characters. Example: 1.- In one terminal run the following script: -----------XMLRPC Server-------------
5
2694
by: Peter Steele | last post by:
We have an application that when it runs in the IDE in debug mode an unhandled exception is occurring in a system header file associated with STL stirngs. The actual statement that crashes is return ::memcmp(_First1, _First2, _Count); On inspecting these variables, the strings are in fact equal when the exception occurs and _Count is the right size. As a test I replaced this code in the system include file with a for loop to do the...
4
1804
by: Larry Tate | last post by:
I am wanting to get those cool html error pages that ms produces when I hit an error in asp.net. For instance, when I get a compilation error I get an html error page that shows me the Description: Compiler Error Message: Source Error: Source File: The main thing I want is the Source Error. This give me a few lines of the
1
3204
by: emielvl | last post by:
Hello, I'm developing a client/server architecture based on the XML-RPC implementation in php4. All works pretty well, except that in the response from the server there is no "Content-Length" in the header. Since the XML-RPC specification requires this header to be present in the server response, some libraries (notably: libxmlrpc++) choke on this. For clarity, here's a (simple) server (slightly altered from:...
3
5847
by: David Hirschfield | last post by:
An xmlrpc client/server app I'm writing used to be super-simple, but now threading has gotten into the mix. On the server side, threads are used to process requests from a queue as they come in. On the client side, threads are used to wait on the results of requests to the server. So the question is: how thread-safe is python xmlrpc? If the client makes a request of the server by calling:
1
2377
by: fortepianissimo | last post by:
I have a simple xmlrpc server/client written in Python, and the client throws a list of lists to the server and gets back a list of lists. This runs without a problem. I then wrote a simple Java xmlrpc client and it calls the python server. But I can't figure out what type to cast the result (of type Object) to. The Java xmlrpc call is basically this: Object result = client.execute("MyFunction", params);
6
2487
by: half.italian | last post by:
Hi, I'm trying to serve up a simple XMLRPC server as a windows service. I got it to run properly, I'm just not sure how to stop it properly. Most of the documentation/examples I found for this was from forums, so I'd love some links to relevant info also. Here's what I have...taken from the cookbook with the xmlrpc server added: import win32serviceutil import win32service
0
7981
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7894
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8284
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8392
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
5847
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3894
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2410
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1500
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.