Commit 9e6183e4 authored by Yong Tang's avatar Yong Tang Committed by Rasmus Munk Larsen
Browse files

Fix error caused in MonitoredSession.close() (#12229)



* Fix error caused in MonitoredSession.close()

This fix tries to address the error raised in 12224:
```
>>> import tensorflow as tf
>>> with tf.train.MonitoredTrainingSession() as sess:
...   sess.close()
...
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 534, in __exit__
    self._close_internal(exception_type)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/monitored_session.py", line 569, in _close_internal
    self._sess.close()
AttributeError: 'NoneType' object has no attribute 'close'
```

The error was caused by double call on `_internal_close()`.

This fix fixes the issue.

This fix fixes 12224

Signed-off-by: default avatarYong Tang <yong.tang.github@outlook.com>

* Add a test case for in MonitoredSession.close() and with statement

This test case covers 12224.

Signed-off-by: default avatarYong Tang <yong.tang.github@outlook.com>
parent d480ac58
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment