]> git.llucax.com Git - software/pymin.git/commitdiff
Bugfix: close() files after use them so the changes get flushed to disk.
authorLeandro Lucarella <llucarella@integratech.com.ar>
Mon, 24 Sep 2007 20:55:49 +0000 (17:55 -0300)
committerLeandro Lucarella <llucarella@integratech.com.ar>
Mon, 24 Sep 2007 20:55:49 +0000 (17:55 -0300)
services/dhcp/__init__.py

index 3d956f94a7152c895c5057a6f2fe3e92a88eef62..7afcd4597d1de241f413af54b7379f0b1f9446d6 100644 (file)
@@ -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
     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."
 
     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 = 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__':
 
 
 if __name__ == '__main__':