Skip to content

Commit ead9032

Browse files
committed
fix: config call and gzipped write
1 parent e97b7f9 commit ead9032

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

nipype/utils/filemanip.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ def loadpkl(infile):
720720
pklopen = gzip.open if infile.suffix == ".pklz" else open
721721

722722
t = time()
723-
timeout = float(config["execution"]["job_finished_timeout"])
723+
timeout = float(config.get("execution", "job_finished_timeout"))
724724
timed_out = True
725725
while (time() - t) < timeout:
726726
try:
@@ -826,8 +826,8 @@ def read_stream(stream, logger=None, encoding=None):
826826

827827

828828
def savepkl(filename, record, versioning=False, sync=False):
829-
with open(filename, "wb") as fobj:
830-
pkl_file = gzip.GzipFile(fileobj=fobj) if filename.endswith(".pklz") else fobj
829+
pkl_open = gzip.open if filename.endswith(".pklz") else open
830+
with pkl_open(filename, "wb") as pkl_file:
831831
if versioning:
832832
from nipype import __version__ as version
833833

@@ -837,9 +837,10 @@ def savepkl(filename, record, versioning=False, sync=False):
837837
pkl_file.write("\n".encode("utf-8"))
838838

839839
pickle.dump(record, pkl_file)
840+
fmlogger.info("Finished saving: {}".format(filename))
840841
if sync:
841-
fobj.flush()
842-
os.fsync(fobj.fileno())
842+
pkl_file.flush()
843+
os.fsync(pkl_file.fileno())
843844

844845

845846
rst_levels = ["=", "-", "~", "+"]

0 commit comments

Comments
 (0)