Permalink
Browse files

Close stdout/stderr file handles explicitly

  • Loading branch information...
1 parent ead91a0 commit f8aee4d1c1ec6bc681f1d94b2e819796b519924b = committed Apr 1, 2013
Showing with 9 additions and 0 deletions.
  1. +9 −0 Bio/Application/__init__.py
@@ -449,6 +449,15 @@ def __call__(self, stdin=None, stdout=True, stderr=True,
if not stderr:
assert not stderr_str, stderr_str
return_code = child_process.returncode
+
+ #Particularly important to close handles on Jython and PyPy
+ #(where garbage collection is less predictable) and on Windows
+ #(where cannot delete files with an open handle):
+ if stdout and isinstance(stdout, basestring):
+ stdout_arg.close()
+ if stderr and isinstance(stderr, basestring) and stdout != stderr:
+ stderr_arg.close()
+
if return_code:
raise ApplicationError(return_code, str(self),
stdout_str, stderr_str)

1 comment on commit f8aee4d

@peterjc
Member
peterjc commented on f8aee4d Apr 2, 2013

Looks like my Windows machine has lost my git user settings or something, but this change was by me.

Please sign in to comment.