public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Gioele Barabucci <gioele@svario.it>
To: Florian Weimer <fweimer@redhat.com>
Cc: Gioele Barabucci via Systemtap <systemtap@sourceware.org>
Subject: Re: [PATCH] dtrace: Use deterministic temp file creation for all temp files
Date: Tue, 28 Feb 2023 04:46:55 +0100	[thread overview]
Message-ID: <9a0b9a4d-c0cb-88eb-499a-e6682b6acdbb@svario.it> (raw)
In-Reply-To: <87edqbko5a.fsf@oldenburg.str.redhat.com>

On 27/02/23 18:34, Florian Weimer wrote:
> * Gioele Barabucci:
> 
>> @@ -380,6 +373,7 @@ def main():
>>           usage()
>>           return 1
>>   
>> +    TEMP_DIR = mkdtemp()
>>       if s_filename != "" and use_cpp:
>>           (ignore, fname) = mktemp_determ(["use_cpp", s_filename], suffix=".d")
>>           cpp = os.environ.get("CPP", "cpp")
>> @@ -458,6 +452,9 @@ def main():
>>           else:
>>               print("cpp: " + s_filename)
>>   
>> +    if not keep_temps:
>> +        os.rmdir(TEMP_DIR)
> 
> This should probably use try:/finally:

You mean wrapping the whole function in a try:/finally: or just the 
`os.rmdir`?

The former implicates a quite invasive refactoring of the code 
(patch-wise a complete rewrite); the latter seems overkill given that 
the other `os.remove` calls are not checked and the only possibilities 
are either silencing the error (pass) or exit with an error code 
(similar to what the exception would do anyway).

> or a context manager with tempfile.TemporaryDirectory.

Wouldn't that greatly complicate the handling of `-k`/`keep_temps`? a 
context manager with `TemporaryDirectory` will unconditionally remove 
the directory and all its content on completion.

BTW, TemporaryDirectory is a Python 3 feature. I understood from the 
code that compatibility with 2.6 is still important in dtrace 
(`sys.version_info > (3,0)`...). Isn't that the case?

Regards,

-- 
Gioele Barabucci

  reply	other threads:[~2023-02-28  3:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-27 12:13 Gioele Barabucci
2023-02-27 15:49 ` Florian Weimer
2023-02-27 15:59   ` Gioele Barabucci
2023-02-27 16:47     ` Florian Weimer
2023-02-27 17:15       ` Gioele Barabucci
2023-02-27 17:34         ` Florian Weimer
2023-02-28  3:46           ` Gioele Barabucci [this message]
2023-02-28 10:12             ` Florian Weimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9a0b9a4d-c0cb-88eb-499a-e6682b6acdbb@svario.it \
    --to=gioele@svario.it \
    --cc=fweimer@redhat.com \
    --cc=systemtap@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).