def show_list(timeout_in_sec, out=sys.stdout, host=jps.env.get_master_host(), sub_port=jps.DEFAULT_SUB_PORT):
    '''get the name list of the topics, and print it
    '''
    class TopicNameStore(object):

        def __init__(self):
            self._topic_names = set()

        def callback(self, msg, topic):
            self._topic_names.add(topic)

        def get_topic_names(self):
            names = list(self._topic_names)
            names.sort()
            return names

    store = TopicNameStore()
    sub = jps.Subscriber('*', store.callback, host=host, sub_port=sub_port)
    sleep_sec = 0.01
    for i in range(int(timeout_in_sec / sleep_sec)):
        sub.spin_once(sleep_sec)
        time.sleep(0.001)  # for context switch
    for name in store.get_topic_names():
        out.write('{}\n'.format(name))
get the name list of the topics, and print it