# Buggy code
def receive_message(self):
    if self.__current_message:
        self.logger.debug("Reusing existing current message as incoming.")
        return self.__current_message

    self.logger.debug("Waiting for incoming message.")
    message = None
    while not message:
        message = self.__source_pipeline.receive()
        if not message:
            self.logger.warning(
                "Empty message received. Some previous bot sent invalid data."
            )
            continue

    # handle a sighup which happened during blocking read
    # TODO: quickfix for https://github.com/certtools/intelmq/issues/1438
    #        self.__handle_sighup()

    try:
        self.__current_message = libmessage.MessageFactory.unserialize(
            message, harmonization=self.harmonization
        )
    except exceptions.InvalidKey as exc:
        # In case a incoming message is malformed an does not conform with the currently
        # loaded harmonization, stop now as this will happen repeatedly without any change
        raise exceptions.ConfigurationError("harmonization", exc.args[0])

    if self.logger.isEnabledFor(logging.DEBUG):
        if "raw" in self.__current_message and len(self.__current_message["raw"]) > 400:
            tmp_msg = self.__current_message.to_dict(hierarchical=False)
            tmp_msg["raw"] = tmp_msg["raw"][:397] + "..."
        else:
            tmp_msg = self.__current_message
        self.logger.debug("Received message %r.", tmp_msg)

    return self.__current_message


# Traceback (intelmq.lib.exceptions.PipelineError)
2019-08-23 02:17:12,380 - maxmind-geoip-expert - INFO - Handling SIGHUP, initializing again now.
2019-08-23 02:17:12,381 - maxmind-geoip-expert - INFO - GeoIPExpertBot initialized with id maxmind-geoip-expert and intelmq 2.1.0.alpha.1 and python 3.4.2 (default, Aug 17 2019, 10:19:24) as process 27276.
2019-08-23 02:17:12,382 - maxmind-geoip-expert - INFO - Bot is starting.
2019-08-23 02:17:12,419 - maxmind-geoip-expert - INFO - Bot initialization completed.
2019-08-23 02:17:12,420 - maxmind-geoip-expert - INFO - Loading source pipeline and queue 'maxmind-geoip-expert-queue'.
2019-08-23 02:17:12,426 - maxmind-geoip-expert - INFO - Acknowledge called.
2019-08-23 02:17:12,427 - maxmind-geoip-expert - ERROR - Pipeline failed.
Traceback (most recent call last):
File "/home/aaron/intelmq/intelmq/lib/bot.py", line 269, in start
self.process()
File "/home/aaron/intelmq/intelmq/bots/experts/maxmind_geoip/expert.py", line 72, in process
self.acknowledge_message()
File "/home/aaron/intelmq/intelmq/lib/bot.py", line 616, in acknowledge_message
self.__source_pipeline.acknowledge()
File "/home/aaron/intelmq/intelmq/lib/pipeline.py", line 132, in acknowledge
raise exceptions.PipelineError("No message to acknowledge.")
intelmq.lib.exceptions.PipelineError: pipeline failed - 'No message to acknowledge.'

# Fixed code
def receive_message(self):
    """


    If the bot is reloaded when waiting for an incoming message, the received message
    will be rejected to the pipeline in the first place to get to a clean state.
    Then, after reloading, the message will be retrieved again.
    """
    if self.__current_message:
        self.logger.debug("Reusing existing current message as incoming.")
        return self.__current_message

    self.logger.debug("Waiting for incoming message.")
    message = None
    while not message:
        message = self.__source_pipeline.receive()
        if not message:
            self.logger.warning(
                "Empty message received. Some previous bot sent invalid data."
            )
            self.__handle_sighup()
            continue

    # * handle a sighup which happened during blocking read
    # * re-queue the message before reloading
    #   https://github.com/certtools/intelmq/issues/1438
    if self.__sighup.is_set():
        self.__source_pipeline.reject_message()
        self.__handle_sighup()
        return self.receive_message()

    try:
        self.__current_message = libmessage.MessageFactory.unserialize(
            message, harmonization=self.harmonization
        )
    except exceptions.InvalidKey as exc:
        # In case a incoming message is malformed an does not conform with the currently
        # loaded harmonization, stop now as this will happen repeatedly without any change
        raise exceptions.ConfigurationError("harmonization", exc.args[0])

    if self.logger.isEnabledFor(logging.DEBUG):
        if "raw" in self.__current_message and len(self.__current_message["raw"]) > 400:
            tmp_msg = self.__current_message.to_dict(hierarchical=False)
            tmp_msg["raw"] = tmp_msg["raw"][:397] + "..."
        else:
            tmp_msg = self.__current_message
        self.logger.debug("Received message %r.", tmp_msg)

    return self.__current_message