Cleanup temp files at exit #435
This commit is contained in:
parent
29cc73ae18
commit
6508128adc
@ -28,6 +28,8 @@ import binascii
|
||||
import gettext
|
||||
import tempfile
|
||||
import logging
|
||||
import atexit
|
||||
import traceback
|
||||
|
||||
_ = lambda msg: gettext.dgettext('sugar-toolkit', msg)
|
||||
|
||||
@ -291,3 +293,13 @@ class TempFilePath(str):
|
||||
else:
|
||||
_tracked_paths[self] -= 1
|
||||
|
||||
def _cleanup_temp_files():
|
||||
logging.debug('_cleanup_temp_files')
|
||||
for path in _tracked_paths.keys():
|
||||
try:
|
||||
os.unlink(path)
|
||||
except:
|
||||
logging.error(traceback.format_exc())
|
||||
|
||||
atexit.register(_cleanup_temp_files)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user