[Zope] RE: ZopeProfiler issue (found root cause)

Pascal Peregrina Pperegrina at Lastminute.com
Mon Jun 27 05:53:31 EDT 2005


I just finished reading xmlrpclib.py and ZopeProfiler code.

Here is the root cause of the issue :

In my code :
 getattr(ServerProxy(self.url),self.rpc_method_expr) returns an
xmlrpclib._Method object

Then ZopeProfiler calls
ZopeProfiler.ZopeProfiler.getHLFuncId(self,fn,frame), which contains:
gP= getattr(s,'getPhysicalPath',None)

So this calls xmlrpclib._Method.__getattr__, which is:
    def __getattr__(self, name):
        return _Method(self.__send, "%s.%s" % (self.__name, name))

So this returns another xmlrpclib._Method object for a "getPhysicalPath" RPC
method

Because gP is not None, ZopeProfiler then does :
p= gP()

And this makes an RPC method call on the service, and of course raises an
Exception !

So for my tests I hacked xmlrpclib._Method.__getattr__ to return None for
'getPhysicalPath' :
    def __getattr__(self, name):
        if name=='getPhysicalPath':
            return None
        return _Method(self.__send, "%s.%s" % (self.__name, name))

But a real fix will be needed on ZopeProfiler !

Thanks.

Pascal

-----Message d'origine-----
De : Pascal Peregrina 
Envoyé : lundi 27 juin 2005 10:42
À : 'zope at zope.org'
Objet : ZopeProfiler issue


Hi,

In a previous mail, I was asking if anyone had issues with ZopeProfiler and
Zope 2.8.
I have made many more tests and my issue is completely unrelated with Zope
2.8 (I got the same issue with Zope 2.7.6)

The issue has to deal with an XML-RPC call to a java service (using the
standard xmlrpclib module).

The code is (method of a class of my own):
    def query(self):
        from xmlrpclib import ServerProxy, loads, ProtocolError
        try:
            if self.protocol=='HTTP GET':
                self.result=loads(urlopen(self.url).read())[0][0]
            elif self.protocol=='XMLRPC':
 
self.result=getattr(ServerProxy(self.url),self.rpc_method_expr)(*self.params
)
        except ProtocolError:
            self.result=None
            self.zeroconf_exception=1
            self.log_exception()
        except SocketError:
            self.result=None
            self.zeroconf_exception=1
            self.log_exception()
        except IOError:
            self.result=None
            self.zeroconf_exception=1
            self.log_exception()
        except:
            self.result=None
            self.log_exception()

This works fine with disabled profiler.

However, when I enable the profiler, I get this error :
Fault: <Fault 0: 'java.lang.Exception: RPC handler object "cat.getProducts"
not found and no default handler registered\n\tat
org.apache.xmlrpc.SelfDocumentingHandlerMapping.getHandler(Ljava.lang.String
;)Ljava.lang.Object;(Unknown Source)\n\tat
org.apache.xmlrpc.XmlRpcWorker.execute(Ljava.io.InputStream;Lorg.apache.xmlr
pc.XmlRpcContext;)[B(XmlRpcWorker.java:183)\n\tat
org.apache.xmlrpc.DocXmlRpcServer.execute(Ljava.io.InputStream;Lorg.apache.x
mlrpc.XmlRpcContext;)[B(Unknown Source)\n\tat
org.apache.xmlrpc.DocXmlRpcServer.execute(Ljava.io.InputStream;Ljava.lang.St
ring;Ljava.lang.String;)[B(Unknown Source)\n\tat
org.apache.xmlrpc.DocXmlRpcWebServer$Connection.run()V(Unknown Source)\n\tat
org.apache.xmlrpc.DocXmlRpcWebServer$Runner.run()V(Unknown Source)\n\tat
java.lang.Thread.run()V(Optimized Method)\n\tat
java.lang.Thread.startThreadFromVM(Ljava.lang.Thread;)V(Optimized
Method)\n'> 

I can reproduce that error if I omit (*self.params) on that line :
 
self.result=getattr(ServerProxy(self.url),self.rpc_method_expr)(*self.params
)

But when I add some logging, self.params looks fine.
Changing that line into :
 
self.result=apply(getattr(ServerProxy(self.url),self.rpc_method_expr),self.p
arams)
Gives the same error.

I also tried hardcoding the arguments, and I still get the same issue !

I don't know what to do, I really need to profile my Zope instance.
So any suggestion would be highly appreciated...

Thanks.

Pascal


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************



More information about the Zope mailing list