[Twisted-Python] addWriter

Andrew Bennetts andrew-twisted at puzzling.org
Tue Oct 29 19:16:12 EST 2002

On Tue, Oct 29, 2002 at 07:00:27PM -0500, Scherbina, Alexander (ASCHERBI) wrote:
> So far, this mechanism works well.  But one of its flaws is the partial
> write situation.  If output buffer overflow occurred, I would like to
> continue doing other things and get called back by the Reactor when the
> socket is writable again.  Moreover, I would like to break the direct
> association between the Queue and the ConnectionFactory.  

Why are having problems with partial writes?  Your Protocol should simply call
self.transport.write(...), which will take care of all the hard work of
sending stuff at the appropriate times.  The Reactor will automatically wake
up the Transport when the socket is ready for writing, and the Transport
will automatically write anything that is waiting to be written.

> Is addWriter/doWrite approach correct?  Or am I going in a totally wrong
> direction?  Please, help, if you can.

It sounds to me like you're going in completely the wrong direction :)

Twisted does all of the hard work for you :)

The idea is you simply say "write this to this connection please" and
Twisted will do everything else... it'll handle partial writes, it'll handle
waiting until the socket is writeable.

Have you read the "Writing Clients" HOWTO?


More information about the Twisted-Python mailing list