Skip to content

Commit ee0d8ef

Browse files
committed
src/sage/parallel/map_reduce.py: replace tmp_dir()
Standard tempfile.TemporaryDirectory() replacement. Issue: #36322
1 parent db73fe9 commit ee0d8ef

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/sage/parallel/map_reduce.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,9 @@
293293
The profiling is activated by the ``profile`` parameter. The value provided
294294
should be a prefix (including a possible directory) for the profile dump::
295295
296-
sage: prof = tmp_dir('RESetMR_profile') + 'profcomp'
297-
sage: res = S.run(profile=prof) # random
296+
sage: import tempfile
297+
sage: d = tempfile.TemporaryDirectory(prefix="RESetMR_profile")
298+
sage: res = S.run(profile=d.name) # random
298299
[RESetMapReduceWorker-1:58] (20:00:41.444) Profiling in
299300
/home/user/.sage/temp/.../32414/RESetMR_profilewRCRAx/profcomp1
300301
...
@@ -309,7 +310,7 @@
309310
:class:`cProfile.Profile` for more details::
310311
311312
sage: import cProfile, pstats
312-
sage: st = pstats.Stats(prof+'0')
313+
sage: st = pstats.Stats(d.name+'0')
313314
sage: st.strip_dirs().sort_stats('cumulative').print_stats() # random
314315
...
315316
Ordered by: cumulative time
@@ -320,6 +321,11 @@
320321
...
321322
<pstats.Stats instance at 0x7fedea40c6c8>
322323
324+
Like a good neighbor we clean up our temporary directory as soon as
325+
possible::
326+
327+
sage: d.cleanup()
328+
323329
.. SEEALSO::
324330
325331
`The Python Profilers <https://docs.python.org/2/library/profile.html>`_

0 commit comments

Comments
 (0)