[Twisted-Python] deferred TCP writes

Brian Granger bgranger at scu.edu
Tue Apr 18 13:44:22 EDT 2006

I have run into this issue as well when trying to order different
writes and make code run _after_ a write was completed.  I ended up
calling my code using deferToThread and putting in time.sleep calls to
make sure things got ordered correctly.  Ugly hack though.

The ITransport interface docs seem to imply that returning a deferred
from a write is not supported:

I make no representations about whether calls to me will happen
immediately or require returning to a control loop, or whether they
will happen in the same or another thread. Consider methods of this
class (aside from getPeer) to be 'thrown over the wall', to happen at
some indeterminate time.

I echo the question: why doesn't write return a deferred?  Surely
there are times you want to trigger events on the completion of a


Brian Granger
Santa Clara University
ellisonbg at gmail.com

More information about the Twisted-Python mailing list