import pickle


def decode_message(msg):
    """Decode a message received via 0MQ

    Given a message received from `recv_multipart`, decode the components.

    Returns a tuple of the form:
        (
            UTF-8 string
            De-pickled data object
        )

    If decoding fails a tuple of None objects will be returned.
    """
    [topic, message] = msg

    try:
        tpc = topic.decode('utf-8')
        msg = pickle.loads(message)
    except:
        tpc = None
        msg = None

    return (tpc, msg)