[Twisted-Python] transport.write clarification

Bob Ippolito bob at redivi.com
Sat Jul 31 15:03:10 MDT 2004


On Jul 31, 2004, at 3:55 PM, George Schlossnagle wrote:

> I'm working on porting the mod_pubsub system to use the twisted 
> framework.  So far things are great, but I have one point of 
> clarificaction.  With all the standard reactors, how are writes 
> handled in a non-blocking manner?  Copying from some of the sample 
> protocols, I have a dataReceived method in my Protocol implementation 
> that looks vaguely like this:
>
> def dataReceived(self, data):
>   self.inbuf += data
>   if self.canReply() == true:
>     self.transport.write(self.response)
>
> My question is: does write() make a non-blocking write, and if so does 
> it reschedule itself later on automatically?  Does it block?  What is 
> the preferred way of handling this?

It makes non-blocking writes until all of the data available is 
written.  It uses a buffer.

-bob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3589 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20040731/c34885bd/attachment-0002.bin>


More information about the Twisted-Python mailing list