# Buggy code
def starting(self, sender, **kwargs):
    print(
        "Starting address: {} identity: {}".format(
            self.core.address, self.core.identity
        )
    )
    try:
        self.reader = DbFuncts(**connection["params"])
    except AttributeError as exc:
        _log.exception(exp)
        self.core.stop()
        return

    self.topic_map = self.reader.get_topic_map()

    if self.core.identity == "platform.historian":
        # Check to see if the platform agent is available, if it isn't then
        # subscribe to the /platform topic to be notified when the platform
        # agent becomes available.
        try:
            ping = self.vip.ping("platform.agent", "awake?").get(timeout=3)
            _log.debug("Ping response was? " + str(ping))
            self.vip.rpc.call(
                "platform.agent", "register_service", self.core.identity
            ).get(timeout=3)
        except Unreachable:
            _log.debug("Could not register historian service")
        finally:
            self.vip.pubsub.subscribe("pubsub", "/platform", self.__platform)
            _log.debug("Listening to /platform")


# Traceback (TypeError)
2015-08-28 08:38:59,118 (forwarderagent-3.0 6934) volttron.platform.agent.base_historian ERROR: An unhandled exception has occured while publishing to historian.
2015-08-28 08:38:59,119 (forwarderagent-3.0 6934) <stderr> ERROR: Traceback (most recent call last):
2015-08-28 08:38:59,119 (forwarderagent-3.0 6934) <stderr> ERROR:   File "/usr/lib/python2.7/logging/__init__.py", line 851, in emit
2015-08-28 08:38:59,120 (forwarderagent-3.0 6934) <stderr> ERROR:     msg = self.format(record)
2015-08-28 08:38:59,120 (forwarderagent-3.0 6934) <stderr> ERROR:   File "/usr/lib/python2.7/logging/__init__.py", line 724, in format
2015-08-28 08:38:59,120 (forwarderagent-3.0 6934) <stderr> ERROR:     return fmt.format(record)
2015-08-28 08:38:59,120 (forwarderagent-3.0 6934) <stderr> ERROR:   File "/home/volttron/volttron-3x/volttron/platform/agent/utils.py", line 228, in format
2015-08-28 08:38:59,121 (forwarderagent-3.0 6934) <stderr> ERROR:     return jsonapi.dumps(dct)
2015-08-28 08:38:59,121 (forwarderagent-3.0 6934) <stderr> ERROR:   File "/home/volttron/volttron-3x/env/local/lib/python2.7/site-packages/zmq/utils/jsonapi.py", line 40, in dumps
2015-08-28 08:38:59,121 (forwarderagent-3.0 6934) <stderr> ERROR:     s = jsonmod.dumps(o, **kwargs)
2015-08-28 08:38:59,122 (forwarderagent-3.0 6934) <stderr> ERROR:   File "/home/volttron/volttron-3x/env/local/lib/python2.7/site-packages/simplejson/__init__.py", line 397, in dumps
2015-08-28 08:38:59,122 (forwarderagent-3.0 6934) <stderr> ERROR:     **kw).encode(obj)
2015-08-28 08:38:59,122 (forwarderagent-3.0 6934) <stderr> ERROR:   File "/home/volttron/volttron-3x/env/local/lib/python2.7/site-packages/simplejson/encoder.py", line 275, in encode
2015-08-28 08:38:59,122 (forwarderagent-3.0 6934) <stderr> ERROR:     chunks = self.iterencode(o, _one_shot=True)
2015-08-28 08:38:59,123 (forwarderagent-3.0 6934) <stderr> ERROR:   File "/home/volttron/volttron-3x/env/local/lib/python2.7/site-packages/simplejson/encoder.py", line 357, in iterencode
2015-08-28 08:38:59,123 (forwarderagent-3.0 6934) <stderr> ERROR:     return _iterencode(o, 0)
2015-08-28 08:38:59,123 (forwarderagent-3.0 6934) <stderr> ERROR:   File "/home/volttron/volttron-3x/env/local/lib/python2.7/site-packages/simplejson/encoder.py", line 252, in default
2015-08-28 08:38:59,124 (forwarderagent-3.0 6934) <stderr> ERROR:     raise TypeError(repr(o) + " is not JSON serializable")
2015-08-28 08:38:59,124 (forwarderagent-3.0 6934) <stderr> ERROR: TypeError: ProtocolError('previous send operation is not complete',) is not JSON serializable
2015-08-28 08:38:59,124 (forwarderagent-3.0 6934) <stderr> ERROR: Logged from file base_historian.py, line 370

# Fixed code
def starting(self, sender, **kwargs):
    print(
        "Starting address: {} identity: {}".format(
            self.core.address, self.core.identity
        )
    )
    try:
        self.reader = DbFuncts(**connection["params"])
    except AttributeError:
        _log.exception("bad connection parameters")
        self.core.stop()
        return

    self.topic_map = self.reader.get_topic_map()

    if self.core.identity == "platform.historian":
        # Check to see if the platform agent is available, if it isn't then
        # subscribe to the /platform topic to be notified when the platform
        # agent becomes available.
        try:
            ping = self.vip.ping("platform.agent", "awake?").get(timeout=3)
            _log.debug("Ping response was? " + str(ping))
            self.vip.rpc.call(
                "platform.agent", "register_service", self.core.identity
            ).get(timeout=3)
        except Unreachable:
            _log.debug("Could not register historian service")
        finally:
            self.vip.pubsub.subscribe("pubsub", "/platform", self.__platform)
            _log.debug("Listening to /platform")