I would like to enqueue items, close the queue to ensure that other sessions will dequeue all remaining items, then reopen it later for the next epoch. Is this possible?
q = tf.FIFOQueue(...)
close_q = q.close()
reopen_q = #???
with tf.Session([...]) as sess:
[...]
sess.run(close_q)
[...]
sess.run(reopen_q)
There's no way to re-open a closed queue, but (only if you are using multiple sessions) there is a workaround::
Create your queue in a with tf.container(name):
block that wraps only the queues, and where name
is not used for any other tf.container()
blocks.
Before you want to reopen the queue, call tf.Session.reset(..., [name])
, where name
is the name of the container you created in step 1. This will cause the queue to be recreated on its next use, and it will be in the opened state.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With