def tearDown(self): automat.CloseLogFile() tmpfile.shutdown() key.ForgetMyKey() my_id.forgetLocalIdentity() settings.shutdown() os.remove('/tmp/_some_priv_key') bpio.rmdir_recursive('/tmp/.bitdust_tmp') bpio.rmdir_recursive('/tmp/_some_folder') os.remove('/tmp/random_file')
def shutdown(): from logs import lg from main import config from system import bpio if _Debug: lg.out(_DebugLevel, 'bpmain.shutdown') if config.conf(): config.conf().removeConfigNotifier('logs/debug-level') from . import shutdowner shutdowner.A('reactor-stopped') from main import events events.shutdown() from automats import automat automat.objects().clear() if len(automat.index()) > 0: lg.warn('%d automats was not cleaned' % len(automat.index())) for a in automat.index().keys(): if _Debug: lg.out(_DebugLevel, ' %r' % a) else: if _Debug: lg.out( _DebugLevel, 'bpmain.shutdown automat.objects().clear() SUCCESS, no state machines left in memory' ) if _Debug: lg.out( _DebugLevel, 'bpmain.shutdown currently %d threads running:' % len(threading.enumerate())) for t in threading.enumerate(): if _Debug: lg.out(_DebugLevel, ' ' + str(t)) if _Debug: lg.out(_DebugLevel, 'bpmain.shutdown finishing and closing log file, EXIT') automat.CloseLogFile() lg.close_log_file() lg.close_intercepted_log_file() if bpio.Windows() and bpio.isFrozen(): lg.stdout_stop_redirecting() from main import settings settings.shutdown() return 0