[Twisted-Python] another probably very simple question

Phil Christensen phil at bubblehouse.org
Mon Nov 17 17:32:44 EST 2003

this is actually the first time i've ever written a PB client in python.
since my java client was calling the remote methods out of the awt/swing
event thread, i never had to deal with this particular issue. while i'm
waiting for the update to the java pb packages (*cough*itamar*cough* ;-)
), i figured it would be worthwhile to do up a text-based client in

i know this relates to my poor understanding of deferreds, but i just
can't figure out exactly how to go about doing what i want to do.

i want to be able to continually prompt the user for a string that gets
sent to a "parse" method on the remote object. i'm not exactly sure the
right way to do this. do I just add a callback to the deferred returned by

def main():
    config = Options()
    if(config['login'] == None):
        config['login'] = getpass.getuser()
    passwd = getpass.getpass("%s@%s's password: " % (config['login'],

    client = TextClient()
    factory = pb.PBClientFactory()
    reactor.connectTCP(config['host'], int(config['port']), factory)
    defer = factory.login(credentials.UsernamePassword(config['login'],
                                                       passwd), client)

def connected(perspective):
    command = raw_input("> ");
    defer = perspective.callRemote("parse", command)

More information about the Twisted-Python mailing list