Skip to content

Commit 7ad241c

Browse files
committed
BF: use TempDirs instance at parser level + atexit to cleanup
I think this is Closes #462
1 parent 8b4b7a0 commit 7ad241c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

heudiconv/parser.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import atexit
12
import logging
23
import os
34
import os.path as op
@@ -13,9 +14,13 @@
1314
from .utils import (
1415
docstring_parameter,
1516
StudySessionInfo,
17+
TempDirs,
1618
)
1719

1820
lgr = logging.getLogger(__name__)
21+
tempdirs = TempDirs()
22+
# Ensure they are cleaned up upon exit
23+
atexit.register(tempdirs.cleanup)
1924

2025
_VCS_REGEX = '%s\.(?:git|gitattributes|svn|bzr|hg)(?:%s|$)' % (op.sep, op.sep)
2126

@@ -66,7 +71,7 @@ def get_extracted_dicoms(fl):
6671
# of all files in all tarballs
6772

6873
# cannot use TempDirs since will trigger cleanup with __del__
69-
tmpdir = mkdtemp(prefix='heudiconvDCM')
74+
tmpdir = tempdirs('heudiconvDCM')
7075

7176
sessions = defaultdict(list)
7277
session = 0

0 commit comments

Comments
 (0)