summaryrefslogtreecommitdiff
path: root/ishtar_common/tasks.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2025-03-26 17:27:41 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2025-06-13 18:08:06 +0200
commit08542121281f492511a2724e8f2c98b6c0c77d8f (patch)
tree02c8c796a2dfabaf9ee018470198ee9255a4fe56 /ishtar_common/tasks.py
parent510b9de8fc74807723d73985a84d494218886db9 (diff)
downloadIshtar-08542121281f492511a2724e8f2c98b6c0c77d8f.tar.bz2
Ishtar-08542121281f492511a2724e8f2c98b6c0c77d8f.zip
🐛 fix unclosed file
Diffstat (limited to 'ishtar_common/tasks.py')
-rw-r--r--ishtar_common/tasks.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/ishtar_common/tasks.py b/ishtar_common/tasks.py
index 55c704ab1..24ae02dcc 100644
--- a/ishtar_common/tasks.py
+++ b/ishtar_common/tasks.py
@@ -173,13 +173,13 @@ def launch_export(export_task_id):
if not export_task.geo:
kwargs["no_geo"] = True
archive_name = full_serialization(**kwargs)
- result = open(archive_name, "rb")
- export_task.result.save(archive_name.split(os.sep)[-1], File(result))
- os.remove(archive_name)
- export_task.finished_date = datetime.datetime.now()
- export_task.state = "F"
- export_task.result_info = str(_("Export finished"))
- export_task.save()
+ with open(archive_name, "rb") as result:
+ export_task.result.save(archive_name.split(os.sep)[-1], File(result))
+ os.remove(archive_name)
+ export_task.finished_date = datetime.datetime.now()
+ export_task.state = "F"
+ export_task.result_info = str(_("Export finished"))
+ export_task.save()
def update_towns():