This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sbt
Recipients georg.brandl, ncoghlan, sbt, serhiy.storchaka, vstinner
Date 2013-09-25.20:07:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1380139639.55.0.91707584668.issue19077@psf.upfronthosting.co.za>
In-reply-to
Content
An alternative would be to use weakref.finalize() which would guarantee that cleanup happens before any purging occurs.  That would allow the use of shutil:

class TemporaryDirectory(object):
    def __init__(self, suffix="", prefix=template, dir=None):
        self.name = mkdtemp(suffix, prefix, dir)
        self._cleanup = weakref.finalize(self, shutil.rmtree, self.name)

    def __enter__(self):
        return self.name

    def __exit__(self, exc, value, tb):
        self._cleanup()

    def cleanup(self):
        self._cleanup()
History
Date User Action Args
2013-09-25 20:07:19sbtsetrecipients: + sbt, georg.brandl, ncoghlan, vstinner, serhiy.storchaka
2013-09-25 20:07:19sbtsetmessageid: <1380139639.55.0.91707584668.issue19077@psf.upfronthosting.co.za>
2013-09-25 20:07:19sbtlinkissue19077 messages
2013-09-25 20:07:19sbtcreate