Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix leaking tempfile handles

  • Loading branch information...
commit 757ff336a47d31e43d22823d629fcced16a8cf75 1 parent 52047e0
@labisso labisso authored
Showing with 11 additions and 1 deletion.
  1. +3 −1 epuharness/fixture.py
  2. +8 −0 epuharness/harness.py
View
4 epuharness/fixture.py
@@ -1,3 +1,4 @@
+import os
import tempfile
from socket import timeout
@@ -105,7 +106,8 @@ def make_fake_libcloud_site(self):
Also creates an instance of the MockEC2NodeDriver for convenience
"""
from epu.mocklibcloud import MockEC2NodeDriver
- _, self.fake_libcloud_db = tempfile.mkstemp()
+ fh, self.fake_libcloud_db = tempfile.mkstemp()
+ os.close(fh)
site_name = 'ec2-fake'
fake_site = {
'name': site_name,
View
8 epuharness/harness.py
@@ -236,6 +236,7 @@ def _build_phantom_authz_file(self, users):
pw_file_contents += "%s\n%s\n" % (user.get('user', ''), user.get('password', ''))
(os_handle, pw_filename) = tempfile.mkstemp()
+ os.close(os_handle)
with open(pw_filename, "w") as pw_f:
pw_f.write(pw_file_contents)
@@ -269,6 +270,7 @@ def _build_phantom_config(self, name, exchange, config, authz_file, logfile=None
config_yaml = yaml.dump(merged_config)
(os_handle, config_filename) = tempfile.mkstemp(suffix='.yml')
+ os.close(os_handle)
with open(config_filename, "w") as config_f:
config_f.write(config_yaml)
@@ -340,6 +342,7 @@ def _build_epum_config(self, name, exchange, config, logfile=None, instance=None
config_yaml = yaml.dump(merged_config)
(os_handle, config_filename) = tempfile.mkstemp(suffix='.yml')
+ os.close(os_handle)
with open(config_filename, "w") as config_f:
config_f.write(config_yaml)
@@ -415,6 +418,7 @@ def _build_provisioner_config(self, name, exchange, config, logfile=None, instan
config_yaml = yaml.dump(merged_config)
(os_handle, config_filename) = tempfile.mkstemp(suffix='.yml')
+ os.close(os_handle)
with open(config_filename, "w") as config_f:
config_f.write(config_yaml)
@@ -485,6 +489,7 @@ def _build_dtrs_config(self, name, exchange, config, logfile=None, instance=None
config_yaml = yaml.dump(merged_config)
(os_handle, config_filename) = tempfile.mkstemp(suffix='.yml')
+ os.close(os_handle)
with open(config_filename, "w") as config_f:
config_f.write(config_yaml)
@@ -565,6 +570,7 @@ def _build_process_dispatcher_config(self, exchange, name, config,
config_yaml = yaml.dump(merged_config)
(os_handle, config_filename) = tempfile.mkstemp(prefix="%s_" % name, suffix='.yml')
+ os.close(os_handle)
with open(config_filename, "w") as config_f:
config_f.write(config_yaml)
@@ -680,6 +686,7 @@ def _build_eeagent_config(self, exchange, name, process_dispatcher,
config_yaml = yaml.dump(config)
(os_handle, config_filename) = tempfile.mkstemp(suffix='.yml')
+ os.close(os_handle)
with open(config_filename, "w") as config_f:
config_f.write(config_yaml)
@@ -817,6 +824,7 @@ def _start_rel(self, name=None, module=None, cls=None, config=None,
rel_yaml = yaml.dump(rel)
(os_handle, rel_filename) = tempfile.mkstemp(suffix='.yml')
+ os.close(os_handle)
with open(rel_filename, "w") as rel_f:
rel_f.write(rel_yaml)
Please sign in to comment.
Something went wrong with that request. Please try again.