[Twisted-Python] newbe twisted xmpp load

Wrene Robyn wrobyn at cox.net
Sun Mar 11 17:43:15 MDT 2007


Thanks for all your help thus far. Here is my code which does run  
with normal select reactor. How to switch it to use poll reactor?  
that is really the crux of my problem.

import sys
import socket
import time
import resource
from threading import Thread
from twisted.words.protocols.jabber import client, jid
from twisted.words.xish import domish
from twisted.internet import reactor

resource.setrlimit(8,[65000,65000])
class testit():

     def authd(xmlstream):
         print "authenticated"

         presence = domish.Element(('jabber:client','presence'))
         xmlstream.send(presence)
     #xmlstream.addObserver('/message',  debug)
     #xmlstream.addObserver('/presence', debug)
     #xmlstream.addObserver('/iq',       debug)

     def debug(elem):
         print elem.toXml().encode('utf-8')
         print "="*20
     for i in range(1,2000):
         print i
         myJid = jid.JID(str(i)+'@jbrsrvrnamt/twisted_words')
         factory = client.basicClientFactory(myJid, 'test')
         factory.addBootstrap('//event/stream/authd',authd)
         reactor.connectTCP('jbrsrvrname',5222,factory)

     reactor.run()

current = testit()
current.start()

On Mar 10, 2007, at 10:54 AM, Jean-Paul Calderone wrote:

> On Sat, 10 Mar 2007 09:24:49 -0500, Wrene Robyn <wrobyn at cox.net>  
> wrote:
>> That throws an error if I import pollreactor in my code, then jid   
>> tries to import reactor, days there is already an instance or  
>> something
>
> You'll have to provide more information than this.  The behavior  
> you describe
> isn't what should happen given the program snippet below, nor what  
> happens
> when I simplify it to just this:
>
>  exarkun at boson:~$ python
>  Python 2.4.3 (#2, Oct  6 2006, 07:52:30)
>  [GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
>  Type "help", "copyright", "credits" or "license" for more  
> information.
>  >>> from twisted.internet import pollreactor
>  >>> pollreactor.install()
>  >>> from twisted.words.protocols.jabber import jid
>  >>> # No error
>
> Generally when you encounter a problem you need help with, the best  
> thing to do
> is to create the simplest possible example which demonstrates the  
> problem and
> include it with your question.  Without this, responders have to  
> guess at what
> you're doing, which leads to incorrect, irrelevant, or ambiguous  
> answers.
>
> 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