You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm in the middle of diagnosing some build instability (files appearing in a directory which I don't expect to be there) and in the process noticed something about .create_tmp -- I'm not sure it's related to my specific issue yet, but to me it seems worth addressing independently. Filing to see what others think.
Specifically... session.create_tmpis documented as "create and return a temporary directory" -- but it actually seems to always use a fixed directory path, tmp, and one that may exist "accidentally" if some other thing happened to create a directory named that, or get polluted accidentally if some other process starts writing to that path.
More surprisingly I think is if someone does this:
they actually are unlikely to realize that they've gotten the same exact path twice there, one and two are going to be the same tmp/ directory.
Describe the solution you'd like
I'd personally definitely expect behavior more like tempfile.TemporaryDirectory and os.mkdtemp, namely that creating temporary directories gives me a path to a directory I can be sure:
didn't exist beforehand
isn't going to be being used by some other process
is going to differ if I call it twice
Describe alternatives you've considered
Certainly just ignoring session.create_tmp is an option, but filing this as it seems a bit like a small footgun as-is.
Anything else?
No response
The text was updated successfully, but these errors were encountered:
It was pointed out to me that create_tmp also sets TMPDIR (which indeed explains my original issue) -- that seems like even more surprising behavior than the first part to me. It now seems worth avoiding this function entirely to me, so going to close this, but obviously if someone agrees with my assessment (on both being quite surprising behavior) and thinks there's some way to nudge it to have less surprising behavior, let me know.
if someone agrees with my assessment (on both being quite surprising behavior) and thinks there's some way to nudge it to have less surprising behavior, let me know.
How would this feature be useful?
I'm in the middle of diagnosing some build instability (files appearing in a directory which I don't expect to be there) and in the process noticed something about
.create_tmp
-- I'm not sure it's related to my specific issue yet, but to me it seems worth addressing independently. Filing to see what others think.Specifically...
session.create_tmp
is documented as "create and return a temporary directory" -- but it actually seems to always use a fixed directory path,tmp
, and one that may exist "accidentally" if some other thing happened to create a directory named that, or get polluted accidentally if some other process starts writing to that path.More surprisingly I think is if someone does this:
they actually are unlikely to realize that they've gotten the same exact path twice there,
one
andtwo
are going to be the sametmp/
directory.Describe the solution you'd like
I'd personally definitely expect behavior more like
tempfile.TemporaryDirectory
andos.mkdtemp
, namely that creating temporary directories gives me a path to a directory I can be sure:Describe alternatives you've considered
Certainly just ignoring
session.create_tmp
is an option, but filing this as it seems a bit like a small footgun as-is.Anything else?
No response
The text was updated successfully, but these errors were encountered: