MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / __exit__

Method __exit__

tensorflow/python/client/session.py:1611–1649  ·  view source on GitHub ↗
(self, exec_type, exec_value, exec_tb)

Source from the content-addressed store, hash-verified

1609 return self._default_session_context_manager.__enter__()
1610
1611 def __exit__(self, exec_type, exec_value, exec_tb):
1612 if exec_type is errors.OpError:
1613 logging.error('Session closing due to OpError: %s', (exec_value,))
1614 try:
1615 self._default_session_context_manager.__exit__(exec_type, exec_value,
1616 exec_tb)
1617 except RuntimeError as error:
1618 if error == exec_value:
1619 # NOTE(skyewm): for some reason, in Python3,
1620 # _default_session_context_manager.__exit__ will re-raise the "not
1621 # re-entrant" exception raised in __enter__ above (note that if we're
1622 # here, we're in the outer session context manager, since __exit__ is
1623 # not called when __enter__ raises an exception). We still want to
1624 # continue cleaning up this context manager before the exception is
1625 # further propagated, so we ignore it here (note that it'll continue
1626 # being propagated after this method completes).
1627 pass
1628 else:
1629 raise
1630 self._default_graph_context_manager.__exit__(exec_type, exec_value, exec_tb)
1631
1632 self._default_session_context_manager = None
1633 self._default_graph_context_manager = None
1634
1635 # If we are closing due to an exception, set a time limit on our Close() to
1636 # avoid blocking forever.
1637 # TODO(b/120204635) remove this when deadlock is fixed.
1638 if exec_type:
1639 close_thread = threading.Thread(
1640 name='SessionCloseThread', target=self.close)
1641 close_thread.daemon = True
1642 close_thread.start()
1643 close_thread.join(30.0)
1644 if close_thread.is_alive():
1645 logging.error(
1646 'Session failed to close after 30 seconds. Continuing after this '
1647 'point may leave your program in an undefined state.')
1648 else:
1649 self.close()
1650
1651 @staticmethod
1652 def reset(target, containers=None, config=None):

Callers 1

closeMethod · 0.45

Calls 6

joinMethod · 0.95
closeMethod · 0.95
errorMethod · 0.80
is_aliveMethod · 0.80
ThreadMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected