From 7d72f80ef780f20f0a122157aa75454d5b0e540b Mon Sep 17 00:00:00 2001 From: Leandro Lucarella Date: Mon, 24 Sep 2007 17:55:49 -0300 Subject: [PATCH] Bugfix: close() files after use them so the changes get flushed to disk. --- services/dhcp/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/dhcp/__init__.py b/services/dhcp/__init__.py index 3d956f9..7afcd45 100644 --- a/services/dhcp/__init__.py +++ b/services/dhcp/__init__.py @@ -218,7 +218,9 @@ class DhcpHandler: def _dump_var(self, var, name): r"_dump_var() -> None :: Dump a especific variable to a pickle file." # XXX podría ir en una clase base - pickle.dump(var, file(self._pickle_filename(name), 'wb'), 2) + pkl_file = file(self._pickle_filename(name), 'wb') + pickle.dump(var, pkl_file, 2) + pkl_file.close() def _load_var(self, name): r"_load_var() -> object :: Load a especific pickle file." @@ -232,6 +234,7 @@ class DhcpHandler: out_file = file(path.join(self.config_dir, config_filename), 'w') ctx = Context(out_file, hosts=self.hosts.values(), **self.vars) self.template.render_context(ctx) + out_file.close() if __name__ == '__main__': -- 2.43.0