[Twisted-Python] xmlrpc protocoll instanze per connection?

Pet petshmidt at googlemail.com
Mon Aug 9 08:07:51 EDT 2010

On Thu, Aug 5, 2010 at 5:01 PM,  <exarkun at twistedmatrix.com> wrote:
> On 02:21 pm, petshmidt at googlemail.com wrote:
>> On Thu, Aug 5, 2010 at 3:32 PM, Alan Franzoni <mailing at franzoni.eu> wrote:
>>> On 8/4/10 1:30 PM, Pet wrote:
>>>> AFAIU this works only if Factory is subclassing
>>>> protocol.ServerFactory, XMLRPCFactory subclasses server.Site, where
>>>> protocol attribute is not present
>>> server.Site subclasses  http.HTTPFactory which, in turns, subclasses
>>> protocol.ServerFactory:
>>> http://twistedmatrix.com/documents/10.0.0/api/twisted.web.server.Site.html
>>> by the way, if I now understand your question: just subclass XMLRPC and
>>> create your own xmlrpc resource class by adding methods like
>>> xmlrpc_somemethod
>>> xmlrpc_othermethod
>>> then add such handler to your server.Site, and you're done. Your method
>>> will be invoked once per request.
>> what I've tried to do is to have objects, which were members of
>> XMLRPC. And these objects would have some internal state which is
>> isolated per request. But each new request has changed this objects,
>> because xmlrpc is created once and not for each request or connection.
>> I've solved this by modifying render_POST where I create those objects
>> before calling requested function and so they lives only there without
>> being overwritten by new request. Ugh... It's might be ugly, but works
>> for me
> If you want a new XMLRPC instance per request, then create a new one per
> request.  http://twistedmatrix.com/documents/current/web/howto/web-in-60
> /dynamic-dispatch.html may help.

This works for me too. getChild() returns for each request new
instance. When is this object destroyed? I've putted print into
__del__, but can't see it in log.


> Re-using a single XMLRPC instance and mangling its state in render_POST will
> break as soon as your server receives two overlapping requests.
> Jean-Paul
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

More information about the Twisted-Python mailing list