Mailinglist Archive: opensuse-buildservice (158 mails)

< Previous Next >
[opensuse-buildservice] [PATCH] build: Do not leave filedescriptors open
  • From: Michal Marek <mmarek@xxxxxxx>
  • Date: Fri, 31 Dec 2010 16:39:18 +0100
  • Message-id: <1293809958-26028-1-git-send-email-mmarek@xxxxxxx>
There is no need for the whole build process to have the _buildinfo* and
_buildconfig* files open.

Signed-off-by: Michal Marek <mmarek@xxxxxxx>
---
osc/build.py | 23 ++++++++++++-----------
1 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/osc/build.py b/osc/build.py
index 3c6aa6c..a77865c 100644
--- a/osc/build.py
+++ b/osc/build.py
@@ -527,14 +527,16 @@ def main(apiurl, opts, argv):
bc_file = None
bi_filename = '_buildinfo-%s-%s.xml' % (repo, arch)
bc_filename = '_buildconfig-%s-%s' % (repo, arch)
+ buildfiles_temporary = False
if is_package_dir('.') and os.access(osc.core.store, os.W_OK):
bi_filename = os.path.join(os.getcwd(), osc.core.store, bi_filename)
bc_filename = os.path.join(os.getcwd(), osc.core.store, bc_filename)
elif not os.access('.', os.W_OK):
- bi_file = NamedTemporaryFile(prefix=bi_filename)
+ bi_file = NamedTemporaryFile(prefix=bi_filename, delete=False)
bi_filename = bi_file.name
- bc_file = NamedTemporaryFile(prefix=bc_filename)
+ bc_file = NamedTemporaryFile(prefix=bc_filename, delete=False)
bc_filename = bc_file.name
+ buildfiles_temporary = True
else:
bi_filename = os.path.abspath(bi_filename)
bc_filename = os.path.abspath(bc_filename)
@@ -565,12 +567,12 @@ def main(apiurl, opts, argv):
specfile=build_descr_data,
addlist=extra_pkgs))
bi_file.write(bi_text)
- bi_file.flush()
+ bi_file.close()
print 'Getting buildconfig from server and store to %s' %
bc_filename
if not bc_file:
bc_file = open(bc_filename, 'w')
bc_file.write(get_buildconfig(apiurl, prj, repo))
- bc_file.flush()
+ bc_file.close()
except urllib2.HTTPError, e:
if e.code == 404:
# check what caused the 404
@@ -788,10 +790,10 @@ def main(apiurl, opts, argv):
rpmlist.append('cbignore: ' + ' '.join(bi.cbpreinstall_list) + '\n')
rpmlist.append('runscripts: ' + ' '.join(bi.runscripts_list) + '\n')

- rpmlist_file = NamedTemporaryFile(prefix='rpmlist.')
+ rpmlist_file = NamedTemporaryFile(prefix='rpmlist.', delete=False)
rpmlist_filename = rpmlist_file.name
rpmlist_file.writelines(rpmlist)
- rpmlist_file.flush()
+ rpmlist_file.close()

subst = { 'repo': repo, 'arch': arch, 'project' : prj, 'package' : pacname
}
vm_options = []
@@ -882,10 +884,9 @@ def main(apiurl, opts, argv):
for i in b_built.splitlines() + s_built.splitlines():
shutil.copy2(i, os.path.join(opts.keep_pkgs,
os.path.basename(i)))

- if bi_file:
- bi_file.close()
- if bc_file:
- bc_file.close()
- rpmlist_file.close()
+ if buildfiles_temporary:
+ os.unlink(bi_filename)
+ os.unlink(bc_filename)
+ os.unlink(rpmlist_filename)

# vim: sw=4 et
--
1.7.3.4

--
To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-buildservice+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages