From 814257fbf841b24fea42d89ae1e61f0a7f810468 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 26 Feb 2021 16:18:58 -0500 Subject: [PATCH] Fix leaking file descriptors When passing a filehandle for update, clean it up on end of the update/upload. --- confluent_server/confluent/firmwaremanager.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/confluent_server/confluent/firmwaremanager.py b/confluent_server/confluent/firmwaremanager.py index 96a4b9d2..5695fd9c 100644 --- a/confluent_server/confluent/firmwaremanager.py +++ b/confluent_server/confluent/firmwaremanager.py @@ -103,6 +103,7 @@ class Updater(object): datfile = os.fdopen(os.dup(cf.fileno()), cf.mode) else: datfile = None + self.datfile = datfile self.updateproc = updatepool.spawn(execupdate, handler, filename, self, type, owner, node, datfile) if type == 'firmware': @@ -127,6 +128,8 @@ class Updater(object): def cancel(self): self.updateproc.kill() + if self.datfile: + self.datfile.close() @property def progress(self):