<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def pub(topic_name, json_msg, repeat_rate=None, host=jps.env.get_master_host(), pub_port=jps.DEFAULT_PUB_PORT):
    '''publishes the data to the topic

    :param topic_name: name of the topic
    :param json_msg: data to be published
    :param repeat_rate: if None, publishes once. if not None, it is used as [Hz].
    '''
    pub = jps.Publisher(topic_name, host=host, pub_port=pub_port)
    time.sleep(0.1)
    if repeat_rate is None:
        pub.publish(json_msg)
    else:
        try:
            while True:
                pub.publish(json_msg)
                time.sleep(1.0 / repeat_rate)
        except KeyboardInterrupt:
            pass