'Register to receive data from a producer.
This sets this selectable to be a consumer for a producer.  When this
selectable runs out of data on a write() call, it will ask the producer
to resumeProducing(). When the FileDescriptor\'s internal data buffer is
filled, it will ask the producer to pauseProducing(). If the connection
is lost, FileDescriptor calls producer\'s stopProducing() method.
If streaming is true, the producer should provide the IPushProducer
interface. Otherwise, it is assumed that producer provides the
IPullProducer interface. In this case, the producer won\'t be asked to
pauseProducing(), but it has to be careful to write() data only when its
resumeProducing() method is called.'

def registerProducer(self, producer, streaming):

    if (self.producer is not None):
        raise RuntimeError(('Cannot    register    producer    %s,    because    producer    %s    was    never    unregistered.' % (producer, self.producer)))
    if self.disconnected:
        producer.stopProducing()
    else:
        self.producer = producer
        self.streamingProducer = streaming
        if (not streaming):
            producer.resumeProducing()
