[issue32234] Add context management to mailbox.Mailbox

Barry A. Warsaw report at bugs.python.org
Wed Dec 6 10:45:38 EST 2017


Barry A. Warsaw <barry at python.org> added the comment:

Yes, I think this is a good idea.  Would you like to submit a PR for it?

FWIW, we have this code in Mailman 3:

class Mailbox(MMDF):
    """A mailbox that interoperates with the 'with' statement."""

    def __enter__(self):
        self.lock()
        return self

    def __exit__(self, *exc):
        self.flush()
        self.unlock()
        # Don't suppress the exception.
        return False

----------
nosy: +barry
versions: +Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32234>
_______________________________________


More information about the Python-bugs-list mailing list