[Twisted-Python] Multicast XMLRPC

Chaz. eprparadocs at gmail.com
Thu Aug 24 12:54:38 EDT 2006


Chaz. wrote:
> radix at twistedmatrix.com wrote:
>> On 03:49 pm, eprparadocs at gmail.com wrote:
>>  >I have a XMLPRC client that works well under TCP and I am now trying 
>> to get
>>  >it to work under Multicast conditions.
>>
>> It is unlikely that you will be able to get the XMLRPC protocol to 
>> work over multicast, given that multicast is an unreliable transport, 
>> like UDP. HTTP and XMLRPC don't know how to deal with that.
>>
>>  >Here is the "TCP" code I used:
>>  >
>>  >class StorageService(internet.TCPServer):
>>  >     def __init__(self,tcpPort,configInfo):
>>  >         r = StoragePeer(configInfo)
>>  >         xmlrpc.addIntrospection(r)
>>  >         internet.TCPServer.__init__(self,tcpPort,server.Site(r))
>>
>>
>> Subclassing the thinks in twisted.application.internet is not really 
>> how those classes are meant to be used. Why did you do this instead of 
>> just instantiating a TCPServer with the appropriate port and factory?
>>
>>  >I changed the call to TCPServer to:
>>  >
>>  >
>>  >class StorageService(internet.TCPServer):
>>  >     def __init__(self,tcpPort,configInfo):
>>  >         r = StoragePeer(configInfo)
>>  >         xmlrpc.addIntrospection(r)
>>  >         internet.MulticastServer.__init__(self,tcpPort,server.Site(r))
>>  >
>>  >I thought this would work since, but it doesn't. What I get returned 
>> is the
>>  >following error message:
>>  >
>>  >
>>  >Failed to load application: unbound method __init__() must be called 
>> with
>>  >MulticastServer instance as first argument (got StorageService instance
>>  >instead)
>>
>> This is a trivial error in your Python. You can't call methods of 
>> classes directly unless the first argument is an instance of that class.
>>
> 
> I know how much work I will need to do to get any UDP-like protocol to 
> work with EXACTLY-ONCE semantics.
> 

It seems my one problem was that in the definition of my class...

class StorageService(internet.TCPServer)

I should have used

class StorageService(internet.MulticastServer)

That solved my immediate problem, though I did find out that XMLRPC does 
in fact assume that you have a connection oriented protocol underneath 
it. Now I will just have to fix that problem.

Also for those of you that said you can't do:

internet.TCPServer.__init__(self,...)

I would suggest you are wrong. In fact that is exactly how subclassing 
works in Python. But that is for another time.

Once again thanks!

Chaz.





More information about the Twisted-Python mailing list