Skip to content

Commit

Permalink
src/sage/parallel/map_reduce.py: replace tmp_dir()
Browse files Browse the repository at this point in the history
Standard tempfile.TemporaryDirectory() replacement.

Issue: #36322
  • Loading branch information
orlitzky committed Oct 10, 2023
1 parent db73fe9 commit ee0d8ef
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/sage/parallel/map_reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,9 @@
The profiling is activated by the ``profile`` parameter. The value provided
should be a prefix (including a possible directory) for the profile dump::
sage: prof = tmp_dir('RESetMR_profile') + 'profcomp'
sage: res = S.run(profile=prof) # random
sage: import tempfile
sage: d = tempfile.TemporaryDirectory(prefix="RESetMR_profile")
sage: res = S.run(profile=d.name) # random
[RESetMapReduceWorker-1:58] (20:00:41.444) Profiling in
/home/user/.sage/temp/.../32414/RESetMR_profilewRCRAx/profcomp1
...
Expand All @@ -309,7 +310,7 @@
:class:`cProfile.Profile` for more details::
sage: import cProfile, pstats
sage: st = pstats.Stats(prof+'0')
sage: st = pstats.Stats(d.name+'0')
sage: st.strip_dirs().sort_stats('cumulative').print_stats() # random
...
Ordered by: cumulative time
Expand All @@ -320,6 +321,11 @@
...
<pstats.Stats instance at 0x7fedea40c6c8>
Like a good neighbor we clean up our temporary directory as soon as
possible::
sage: d.cleanup()
.. SEEALSO::
`The Python Profilers <https://docs.python.org/2/library/profile.html>`_
Expand Down

0 comments on commit ee0d8ef

Please sign in to comment.