[Twisted-Python] Twisted sure is Twisted :)

John Janecek jjanecek at telusplanet.net
Sat Aug 30 04:34:58 MDT 2003


Twisted once u get a grip on it sure is pretty impressive.
I used twisted to forward UDP packets as a relay. Take one
UDP packet and then retrans it to many other clients. On
a FreeBSD box P3 750 the delay in retrans on packet to
like 5 clients was less then 1ms which was very impressive.

In using twisted i know the reactor is broken in wxpython.

What would happen if u ran a normal reactor in a seperate thread,
and then passed the info from twisted into wxpython using an event
handler similar to the wxpython thread demo ??

The only problem with that is i can not see how u would pass info
from wxpython back into twisted. Hmmmm maybe if u made a queue,
and then passed the commands onto a queue and then the reactor would
pull them off. Something to ponder :). Solution on ActiveState cookbook
will work, but i do not like timers.

The idea behind deferred is intresting. The defered call back does not seem
to fire until it is added. How the heck does that work ? I am refering to the
database example. Hmmmm not really important but kinda neat.

def getAge(user):
     return dbpool.runQuery("SELECT age FROM users WHERE name = ?", user)

def printResult(l):
     if l:
         print l[0][0], "years old"
     else:
         print "No such user"

d=getAge("joe")
d.addCallback(printResult)

like here d is the function getAge. My gut instict tell me the moment I 
call getAge
the database query should be run. But yet it is not run till u add the 
callback.
and if i add an errorback after it, it is not run till it has been added 
also, I can
not see how it works :)). Hmmmm must be part of the magic :))

Starting to look into woven. Basic examples are impressive. It is a real
object oriented web design. In the sandbox on CVS in the directory glyph
there is an example on forms. I am unable to get it to work. It runs but 
eveytime
I try and make it work I get in my browser the error no such child 
resource. I guess
I have to keep pluggin away at it :). My limited experience shows i need to 
change
my thinking, since twisted is not a "API" system like PHP, but more of a 
framework.
Maybe it would help if i drank a bottle of vodka first :)

I guess the only complaint i have about twisted is lack of woven examples, 
like for
forms and guard. But heya it is opensource and free, so if i do not like it 
I can
use some crappy comercial product :)).

Anyways Twisted is really cool. A lot of it seems to be very magical :). 
Pondering whether
I should get rid of my apache server and run a twisted one :)).

Anyway this is the crap i ramble off at 4 am :)
Just basically wanted to say twisted is cool.






More information about the Twisted-Python mailing list