def initialize(self, *args, **kwds):
"""Initialize the scenario tree manager.
A scenario tree manager must be initialized before using it.
"""
init_start_time = time.time()
result = None
try:
if self._options.verbose:
print("Initializing %s with options:"
% (type(self).__name__))
self.display_options()
print("")
############# derived method
result = self._init(*args, **kwds)
#############
if self._options.verbose:
print("%s is successfully initialized"
% (type(self).__name__))
except:
if not self._inside_with_block:
print("Exception encountered. Scenario tree manager "
"attempting to shut down.")
print("Original Exception:")
traceback.print_exception(*sys.exc_info())
self.close()
raise
if self._options.output_times or \
self._options.verbose:
print("Overall initialization time=%.2f seconds"
% (time.time() - init_start_time))
# gather and report memory statistics (for leak
# detection purposes) if specified.
if self._options.profile_memory:
if guppy_available:
print(hpy().heap())
else:
print("Guppy module is unavailable for "
"memory profiling")
self._initialized = True
return result
评论列表
文章目录