Mailinglist Archive: opensuse-buildservice (148 mails)

< Previous Next >
Re: [opensuse-buildservice] [PATCH] build: Do not leave filedescriptors open
On 2.1.2011 23:37, Marcus Hüwe wrote:
On 2010-12-31 16:39:18 +0100, Michal Marek wrote:
There is no need for the whole build process to have the _buildinfo* and
_buildconfig* files open.

Hmm with this patch it might be possible that the temporary file isn't
unlinked (because you call NamedTemporaryFile with "delete=False").
For instance if an exception is raised before the
"if buildfiles_temporary..." check is reached the tempfiles won't be
unlinked (with "delete=True" the file will be removed whenever the
_TemporaryFileWrapper instance is "deleted").
I need to think about it again (because I want to avoid a big
try-finally block)...

Thanks for the review. Would it be possible to subclass
_TemporaryFileWrapper to only unlink the file if the object is destroyed
and not when it is closed? Or is this an "internal" class, because it is
underscore-prefixed? Or we can leave it as is, I just stumbled upon the
open fds when debugging something unrelated during build.

BTW, I find the default behavior of NamedTemporaryFile() rather odd, I
would expect that

open temporary file
write data to it
close it
pass the filename to an external process
delete the file

would be a common pattern.

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

< Previous Next >