From 8047c1881ccc176b522a23d84ea3fcc75e8342a3 Mon Sep 17 00:00:00 2001 From: Ansgar Wehrhahn <31626864+AWehrhahn@users.noreply.github.com> Date: Thu, 8 Jul 2021 14:04:52 +0200 Subject: [PATCH] add async saving of sme files --- src/pysme/persistence.py | 7 +++++-- src/pysme/sme.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pysme/persistence.py b/src/pysme/persistence.py index c36a3c88..aa0ea903 100644 --- a/src/pysme/persistence.py +++ b/src/pysme/persistence.py @@ -49,7 +49,7 @@ def from_flex(ff, sme): return sme -def save(filename, sme, format="flex"): +def save(filename, sme, format="flex", _async=False): """ Create a folder structure inside a tarfile See flex-format for details @@ -73,7 +73,10 @@ def save(filename, sme, format="flex"): filename = filename + file_ending if format == "flex": - ff.write(filename) + if _async: + ff.write_async(filename) + else: + ff.write(filename) elif format == "fits": ff.to_fits(filename, overwrite=True) elif format == "json": diff --git a/src/pysme/sme.py b/src/pysme/sme.py index 74d69ee8..54a235fb 100644 --- a/src/pysme/sme.py +++ b/src/pysme/sme.py @@ -696,7 +696,7 @@ def citation(self, output="string"): return self.create_citation(citation, output=output) - def save(self, filename, format="flex"): + def save(self, filename, format="flex", _async=False): """Save the whole SME structure to disk. The file format is zip file, with one info.json @@ -711,7 +711,7 @@ def save(self, filename, format="flex"): compressed : bool, optional whether to compress the output, by default False """ - persistence.save(filename, self, format=format) + persistence.save(filename, self, format=format, _async=_async) @staticmethod def load(filename):