[Twisted-Python] High-level view of Twisted

Jason Heeris jason.heeris at gmail.com
Mon Jan 31 23:58:54 EST 2011


Hi,

I'd like to come to grips with Twisted, and so far I've been following
and tweaking example after example. But I'm finding it incredibly hard
to get a high level view of the Twisted "landscape" — and because I
don't know what I don't know, it's hard to know what questions to even
ask. I want to get to the point where I can just sit down and know
where to start, and hopefully someone here can give me a bit of
direction.

I understand many of the microscopic components. Deferred results,
file descriptors and sockets, the reactor loop concept — I get those.
I've read the tutorial[1], another Twisted Introduction[2], and about
50% of the API documentation (possibly not the right 50%, though).

But I just can't seem to wrap my head around the interfaces, factories
and wiring it all together. Maybe some examples of the speedbumps I
keep encountering will help:

1. The "finger" intro "Drop Connections" example[3] just straight out
uses the self.transport member of a protocol. But how do I, a Twisted
newbie, know that this even exists? After hours of digging around, I
find it in the docs for a BaseProtocol method[4]. Later on, this same
example uses the "self.factory" member. I still haven't found that
one. Where do I look up these assumed-to-exist members? How do I know
what other members exist?

2. What is a Factory, anyway? What are they *for*?

3. The finger example goes over writing a server — what about an
asynchronous client that must follow a particular protocol? Where do I
start with that? Is there an example?

4. What if I'm not interested in networking? I primarily deal with
serial lines, files and subprocesses... are there examples for those?

Points #3 and #4 are my motivation for using Twisted — I am currently
mired in a pygtk program that uses threads and all sorts of locks and
synchronisation mechanisms to send and receive data over a serial
line, updating UI with progress, errors and success. I'd like to see
if using Twisted simplifies things a bit, and I'll ask a more specific
question about how to structure that when I can condense it to a
reasonable level :)

I hope I'm not being too vague, but Twisted is rather large,
conceptually, to absorb. I keep being pointed to the documentation for
specific parts, but I have no idea how they fit together and that's
what I'm really after.

Thanks,
Jason

[1] http://twistedmatrix.com/documents/current/core/howto/tutorial/index.html
[2] http://krondo.com/?page_id=1327
[3] http://twistedmatrix.com/documents/current/core/howto/tutorial/intro.html#auto4
[4] http://twistedmatrix.com/documents/current/api/twisted.internet.protocol.BaseProtocol.html#makeConnection



More information about the Twisted-Python mailing list