Message149271
I would like to see this posted as a recipe before being put in the standard library. It needs a chance to mature and to demonstrate that people will want to use it.
FWIW, the example is problematic in a couple of ways. The registration of shutil.rmtree(tmpdir) will run *before* mngr register is called.
Also, it doesn't take advantage of any of the with-statement features. It doesn't show any advantage over a standard try/finally which is arguably cleaner:
tmpdir = tempfile.mkdtemp()
try:
# do stuff with tmpdir
finally:
shutil.rmtree()
Also, I suspect that the CleanupManager would be an error-prone construct because the registration occurs somewhere after the with-statement is set-up, possibly resulting in errors if there is an early, pre-registration failure. |
|
Date |
User |
Action |
Args |
2011-12-12 02:41:24 | rhettinger | set | recipients:
+ rhettinger, nikratio |
2011-12-12 02:41:24 | rhettinger | set | messageid: <1323657684.72.0.423067063412.issue13585@psf.upfronthosting.co.za> |
2011-12-12 02:41:24 | rhettinger | link | issue13585 messages |
2011-12-12 02:41:23 | rhettinger | create | |
|