twisted :: internet :: process :: ProcessWriter :: Class ProcessWriter
[frames] | no frames]

Class ProcessWriter

             object --+        
                      |        
abstract._ConsumerMixin --+    
                          |    
             object --+   |    
                      |   |    
     abstract._LogOwner --+    
                          |    
    abstract.FileDescriptor --+
                              |
                             ProcessWriter

(Internal) Helper class to write into a Process's input pipe.

I am a helper which describes a selectable asynchronous writer to a process's input pipe, including stdin.

Instance Methods
 
__init__(self, reactor, proc, name, fileno, forceReadHack=False)
Initialize, specifying a Process instance to connect to.
 
fileno(self)
Return the fileno() of my process's stdin.
 
writeSomeData(self, data)
Write some data to the open process.
 
write(self, data)
Reliably write some data.
 
doRead(self)
The only way a write pipe can become "readable" is at EOF, because the child has closed it, and we're using a reactor which doesn't distinguish between readable and closed (such as the select reactor).
 
connectionLost(self, reason)
See abstract.FileDescriptor.connectionLost.

Inherited from abstract.FileDescriptor: __provides__, doWrite, loseConnection, loseWriteConnection, pauseProducing, readConnectionLost, resumeProducing, startReading, startWriting, stopConsuming, stopProducing, stopReading, stopWriting, writeConnectionLost, writeSequence

Inherited from abstract._ConsumerMixin: __providedBy__, registerProducer, unregisterProducer

Inherited from abstract._LogOwner: logPrefix

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  connected = 1
  ic = 0

Inherited from abstract.FileDescriptor: SEND_LIMIT, __implemented__, bufferSize, dataBuffer, disconnected, disconnecting, offset, producer

Instance Variables
  enableReadHack = False
A flag which determines how readability on this write descriptor will be handled.

Inherited from abstract._ConsumerMixin: producerPaused, streamingProducer

Properties

Inherited from object: __class__

Method Details

__init__(self, reactor, proc, name, fileno, forceReadHack=False)
(Constructor)

 

Initialize, specifying a Process instance to connect to.

Overrides: object.__init__

fileno(self)

 

Return the fileno() of my process's stdin.

Overrides: abstract.FileDescriptor.fileno

writeSomeData(self, data)

 

Write some data to the open process.

Overrides: abstract.FileDescriptor.writeSomeData

write(self, data)

 

Reliably write some data.

The data is buffered until the underlying file descriptor is ready for writing. If there is more than self.bufferSize data in the buffer and this descriptor has a registered streaming producer, its pauseProducing() method will be called.

Overrides: abstract.FileDescriptor.write
(inherited documentation)

doRead(self)

 

The only way a write pipe can become "readable" is at EOF, because the child has closed it, and we're using a reactor which doesn't distinguish between readable and closed (such as the select reactor).

Except that's not true on linux < 2.6.11. It has the following characteristics: write pipe is completely empty => POLLOUT (writable in select), write pipe is not completely empty => POLLIN (readable in select), write pipe's reader closed => POLLIN|POLLERR (readable and writable in select)

That's what this funky code is for. If linux was not broken, this function could be simply "return CONNECTION_LOST".

BUG: We call select no matter what the reactor. If the reactor is pollreactor, and the fd is > 1024, this will fail. (only occurs on broken versions of linux, though).

Overrides: abstract.FileDescriptor.doRead

connectionLost(self, reason)

 

See abstract.FileDescriptor.connectionLost.

Overrides: abstract.FileDescriptor.connectionLost

Instance Variable Details

enableReadHack

A flag which determines how readability on this write descriptor will be handled. If True, then readability may indicate the reader for this write descriptor has been closed (ie, the connection has been lost). If False, then readability events are ignored.
Value:
False