[Twisted-Python] Help using XmlStreamFactory & XmlStream : XPathQuery error?

Gabriel Rossetti mailing_lists at evotex.ch
Thu Feb 21 03:13:04 EST 2008

Jean-Paul Calderone wrote:
> On Wed, 20 Feb 2008 16:19:52 +0100, Gabriel Rossetti 
> <mailing_lists at evotex.ch> wrote:
>> [snip]
>> And if I'm not mistaking, if I have multiple connections, then the 
>> events get mixed up (from my own tests anyways), the processing is 
>> not atomic. If I have let's say that I have :
>> client1 : <test><header  id="1"/>
>> client2 : <test><header  id="2"/><feed name="myName">toto</feed></test>
>> client2 : <feed name="myName2">lala</feed></test>
> I think the 3rd line should be client1?
>> my stanzas will get processed in that order, thus I can't even 
>> recreate the message (without a complicated state machine of some kind).
>> I'm kind of mixed up, because when using a thread based network 
>> framework, one tcp connection = one thread, thus the protocol 
>> execution is atomic, but this doesn't seam to be the case with 
>> Twisted (event based), is this correct or have I missed something again?
> If you send all events to a single function with no indication of 
> where they
> came from, then you will certainly have difficulty figuring out what's 
> going
> on.  So, don't do that. ;)
> One solution is to have a difference instance for each connection and 
> to use
> a bound method as the event handler.  This gives you an obvious 
> per-instance
> place to keep state and such - on the instance.  

Jean-Paul, sorry for the dumb question, when you mean a different 
instance, you mean a thread? What is a bound method? I'm fairly new to 
python and very new to twisted (as you can probably tell).

Thank you! Gabriel

> There are other solutions,
> of course, like passing in some extra object to the event handler so 
> you can
> differentiate between clients.
> If you use instances and bound methods, then client1's stanzas will be 
> sent
> to the instance you created to handle client1 and client2's stanzas 
> will be
> sent to the instance you created to handle client2.  This way, it 
> should be
> trivial to keep track of what's going on.
> 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