def sg_queue_context(sess=None):
    r"""Context helper for queue routines.

    Args:
      sess: A session to open queues. If not specified, a new session is created.

    Returns:
      None
    """

    # default session
    sess = tf.get_default_session() if sess is None else sess

    # thread coordinator
    coord = tf.train.Coordinator()
    try:
        # start queue thread
        threads = tf.train.start_queue_runners(sess, coord)
        yield
    finally:
        # stop queue thread
        coord.request_stop()
        # wait thread to exit.
        coord.join(threads)
def sg_queue_context ( sess = None ) : sess = tf . get_default_session ( ) if sess is None else sess coord = tf . train . Coordinator ( ) try : threads = tf . train . start_queue_runners ( sess , coord ) yield finally : coord . request_stop ( ) coord . join ( threads )
r"""Context helper for queue routines.

    Args:
      sess: A session to open queues. If not specified, a new session is created.

    Returns:
      None