[Twisted-Python] <no subject>

Fabian Rothfuchs fabian.rothfuchs at googlemail.com
Mon Sep 19 06:44:55 MDT 2011


Hi Guys,

I'm relatively new to Twisted (as the most questioners I guess).
Without providing tons of distracting details, this is where I'm stuck w/
Twisted:

I currently build a server application that consists of a set of client
adapters, which (among others) use Telnet as transport protocol ­ so I chose
to use Twisted to write the client.
I already have all clients in place in an autarkic Twisted implementation
and it works just fine ­ thus, the crux is to get those autarkic snippets
under one reactor-hood.
As this application should ideally server forever, stopping the reactor
would mean to stop the whole application, which conflicts with it's
ideology.
During the night, the application will be fed new tasks ­ depending on what
those tasks are, the application needs to run specific workflows using
different adapters (and protocols).

Having said this, when starting the application (and hence the reactor), I'm
not yet aware of the following:
- which adapters I will need during
- when the connections are triggered

But all implementation examples and documentations I've found expect those
information to be present and provided to the reactor, prior to it's run():

for host in hosts:

    host, port = (host, 23)

    d = defer.Deferred()

    from twisted.internet import reactor

    factory = S12ClientFactory(d, username='root', password='admin')

    Connection = reactor.connectTCP(host, port, factory, timeout=5)

    d.addCallbacks(success, error)

    d.addBoth(logout)

reactor.run()


So I wonder, if you can dynamically feed the reactor with new tasks (I use
connectTCP for it), as it's not possible to start/stop it on demand (or if
there's an alternative approach):

from twisted.internet import reactor

reactor.run()

for host in hosts:

    host, port = (host, 23)

    d = defer.Deferred()

    factory = S12ClientFactory(d, username='root', password='admin')

    Connection = reactor.connectTCP(host, port, factory, timeout=5)

    d.addCallbacks(success, error)

    d.addBoth(logout)


If I try to do so, connection.state never leaves 'connecting' and I cannot
see any traffic going through the wire on the TCPDump?
I'd really appreciate any hints, as I'm feeling a bit lost :-)

Thanks
Fabian


-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20110919/7f455c79/attachment.html>


More information about the Twisted-Python mailing list