Conversation
|
Documentation preview for this PR (built with commit b9f3011; changes) is ready! 🎉 |
|
I think this works because It should be fine but can you please leave a comment explaining why |
For some reason, a new behaviour of python 3.13 [0] causes the `TemporaryDirectory()` in `sage.misc.temporary_file.spyx_tmp()` to be deleted on child exit, which causes trouble with parallel doctesting [1]. We rewrite `spyx_tmp()` using `tmp_dir()`, which doesn't have this problem, see [2]. [0] python/cpython#114279 [1] sagemath#39188 (comment) [2] sagemath#39188 (comment)
1e5947a to
9669a86
Compare
I don't think so:
The only reason you got away with this is because on python 3.12 and earlier python objects are not finalized when a child exits, skipping the side effect of the
Ok, done. |
|
While we're at it, This docstring is very wrong. Looks like the implementation has changed long ago. (but the |
| atexit.register(lambda: d.cleanup()) | ||
| # We don't use `tempfile.TemporaryDirectory()` here because it | ||
| # will be cleaned up on child exit (e.g. for parallel testing) | ||
| # For some reason this doesn't affect the `TemporaryDirectory` |
There was a problem hiding this comment.
Using tempfile.TemporaryDirectory() works just fine for me, so this comment may not be completely correct (however, it is not cleaned up on exit of the parent process)
There was a problem hiding this comment.
Hmmm.. so you mean TemporaryDirectory() is not cleaning up on program exit in general, or only in sage.misc.temporary_file.spyx_tmp()? What about sage.misc.temporary_file.TMP_DIR_FILENAME_BASE?
There was a problem hiding this comment.
Only on spyx_tmp(). The TMP_DIR_FILENAME_BASE one is cleaned up correctly
There was a problem hiding this comment.
So, there seems to be something fragile about using TemporaryDirectory() on a local variable that is meant to survive its function. There are no clear rules about when this object will be destroyed (apparently the lambda: d.cleanup() grabs a reference that stays in the atexit hook, but I'm not sure if the lambda takes a strong reference).
I guess the "right" way to acomplish what was intended here might be to store d in the global variable, and not just d.name.
There was a problem hiding this comment.
I expanded the comment to mention that several different behaviors can happen.
@antonio-rojas can you have a look and maybe approve this? We are shipping this in the void linux package for sagemath 10.5.
There was a problem hiding this comment.
Sure, I'm shipping this too and have run the test suite in parallel a few times.
|
I… still don't understand why this patch may work.
Though it sound like a good idea to put all the temporary stuff into the same place anyway. |
No, because |
IIUC, But my problem is not the atexit hook removing the directory. It's the weakref.finalize for the Arguably, a bug in |
sagemathgh-39188: Declare Python 3.13 as supported in sagelib ### ⌛ Dependencies - sagemath#39145 - sagemath#39147 - sagemath#39182 - sagemath#39184 - sagemath#39185 - sagemath#39187 - sagemath#39201 URL: sagemath#39188 Reported by: Antonio Rojas Reviewer(s): Tobias Diez
sagemathgh-39201: Fix `spyx_tmp()` cleanup. For some reason, a new behaviour of python 3.13 [0] causes the `TemporaryDirectory()` in `sage.misc.temporary_file.spyx_tmp()` to be deleted on child exit, which causes trouble with parallel doctesting [1]. We rewrite `spyx_tmp()` using `tmp_dir()`, which doesn't have this problem, see [2]. [0] python/cpython#114279 [1] sagemath#39188 (comment) [2] sagemath#39188 (comment) In addition, use `sage_` prefix for the main temporary directory. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. URL: sagemath#39201 Reported by: Gonzalo Tornaría Reviewer(s): Antonio Rojas, Gonzalo Tornaría
sagemathgh-39188: Declare Python 3.13 as supported in sagelib ### ⌛ Dependencies - sagemath#39145 - sagemath#39147 - sagemath#39182 - sagemath#39184 - sagemath#39185 - sagemath#39187 - sagemath#39201 URL: sagemath#39188 Reported by: Antonio Rojas Reviewer(s): Tobias Diez
sagemathgh-39201: Fix `spyx_tmp()` cleanup. For some reason, a new behaviour of python 3.13 [0] causes the `TemporaryDirectory()` in `sage.misc.temporary_file.spyx_tmp()` to be deleted on child exit, which causes trouble with parallel doctesting [1]. We rewrite `spyx_tmp()` using `tmp_dir()`, which doesn't have this problem, see [2]. [0] python/cpython#114279 [1] sagemath#39188 (comment) [2] sagemath#39188 (comment) In addition, use `sage_` prefix for the main temporary directory. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. URL: sagemath#39201 Reported by: Gonzalo Tornaría Reviewer(s): Antonio Rojas, Gonzalo Tornaría
sagemathgh-39188: Declare Python 3.13 as supported in sagelib ### ⌛ Dependencies - sagemath#39145 - sagemath#39147 - sagemath#39182 - sagemath#39184 - sagemath#39185 - sagemath#39187 - sagemath#39201 URL: sagemath#39188 Reported by: Antonio Rojas Reviewer(s): Tobias Diez
sagemathgh-39201: Fix `spyx_tmp()` cleanup. For some reason, a new behaviour of python 3.13 [0] causes the `TemporaryDirectory()` in `sage.misc.temporary_file.spyx_tmp()` to be deleted on child exit, which causes trouble with parallel doctesting [1]. We rewrite `spyx_tmp()` using `tmp_dir()`, which doesn't have this problem, see [2]. [0] python/cpython#114279 [1] sagemath#39188 (comment) [2] sagemath#39188 (comment) In addition, use `sage_` prefix for the main temporary directory. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. URL: sagemath#39201 Reported by: Gonzalo Tornaría Reviewer(s): Antonio Rojas, Gonzalo Tornaría
sagemathgh-39188: Declare Python 3.13 as supported in sagelib ### ⌛ Dependencies - sagemath#39145 - sagemath#39147 - sagemath#39182 - sagemath#39184 - sagemath#39185 - sagemath#39187 - sagemath#39201 URL: sagemath#39188 Reported by: Antonio Rojas Reviewer(s): Tobias Diez
sagemathgh-39201: Fix `spyx_tmp()` cleanup. For some reason, a new behaviour of python 3.13 [0] causes the `TemporaryDirectory()` in `sage.misc.temporary_file.spyx_tmp()` to be deleted on child exit, which causes trouble with parallel doctesting [1]. We rewrite `spyx_tmp()` using `tmp_dir()`, which doesn't have this problem, see [2]. [0] python/cpython#114279 [1] sagemath#39188 (comment) [2] sagemath#39188 (comment) In addition, use `sage_` prefix for the main temporary directory. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. URL: sagemath#39201 Reported by: Gonzalo Tornaría Reviewer(s): Antonio Rojas, Gonzalo Tornaría
sagemathgh-39188: Declare Python 3.13 as supported in sagelib ### ⌛ Dependencies - sagemath#39145 - sagemath#39147 - sagemath#39182 - sagemath#39184 - sagemath#39185 - sagemath#39187 - sagemath#39201 URL: sagemath#39188 Reported by: Antonio Rojas Reviewer(s): Tobias Diez
sagemathgh-39201: Fix `spyx_tmp()` cleanup. For some reason, a new behaviour of python 3.13 [0] causes the `TemporaryDirectory()` in `sage.misc.temporary_file.spyx_tmp()` to be deleted on child exit, which causes trouble with parallel doctesting [1]. We rewrite `spyx_tmp()` using `tmp_dir()`, which doesn't have this problem, see [2]. [0] python/cpython#114279 [1] sagemath#39188 (comment) [2] sagemath#39188 (comment) In addition, use `sage_` prefix for the main temporary directory. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. URL: sagemath#39201 Reported by: Gonzalo Tornaría Reviewer(s): Antonio Rojas, Gonzalo Tornaría
sagemathgh-39188: Declare Python 3.13 as supported in sagelib ### ⌛ Dependencies - sagemath#39145 - sagemath#39147 - sagemath#39182 - sagemath#39184 - sagemath#39185 - sagemath#39187 - sagemath#39201 URL: sagemath#39188 Reported by: Antonio Rojas Reviewer(s): Tobias Diez
For some reason, a new behaviour of python 3.13 [0] causes the
TemporaryDirectory()insage.misc.temporary_file.spyx_tmp()to be deleted on child exit, which causes trouble with parallel
doctesting [1].
We rewrite
spyx_tmp()usingtmp_dir(), which doesn't have thisproblem, see [2].
[0] python/cpython#114279
[1] #39188 (comment)
[2] #39188 (comment)
In addition, use
sage_prefix for the main temporary directory.📝 Checklist