def METHOD_NAME(
    self, producer: Union[IPushProducer, IPullProducer], streaming: bool
) -> None:
    """Part of IConsumer interface
    Args:
        producer
        streaming: True if push based producer, False if pull
            based.
    """
    if self._producer:
        raise Exception("registerProducer called twice")
    self._producer = producer
    self.streaming = streaming
    self._finished_deferred = run_in_background(
        threads.deferToThreadPool,
        self._reactor,
        self._reactor.getThreadPool(),
        self._writer,
    )
    if not streaming:
        self._producer.resumeProducing()