diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2006-11-17 16:16:28 +0000 |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2006-11-17 16:16:28 +0000 |
commit | 830358af099ebafe0e32fb4bcbcf931d608664b5 (patch) | |
tree | 3632e6a6e07da77d91430248ef355140bd09bbca /Lib/mailbox.py | |
parent | dd3bffb679f8c76ffb1ac9a9a4a7fb515e0f4447 (diff) | |
download | cpython-git-830358af099ebafe0e32fb4bcbcf931d608664b5.tar.gz |
Remove locking of individual message files in MH.pack().
[Backport of rev52776 from the trunk.]
Diffstat (limited to 'Lib/mailbox.py')
-rwxr-xr-x | Lib/mailbox.py | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/Lib/mailbox.py b/Lib/mailbox.py index c6b0fa00e3..108d874fe0 100755 --- a/Lib/mailbox.py +++ b/Lib/mailbox.py @@ -1054,27 +1054,13 @@ class MH(Mailbox): for key in self.iterkeys(): if key - 1 != prev: changes.append((key, prev + 1)) - f = open(os.path.join(self._path, str(key)), 'r+') - try: - if self._locked: - _lock_file(f) - try: - if hasattr(os, 'link'): - os.link(os.path.join(self._path, str(key)), - os.path.join(self._path, str(prev + 1))) - if sys.platform == 'os2emx': - # cannot unlink an open file on OS/2 - f.close() - os.unlink(os.path.join(self._path, str(key))) - else: - f.close() - os.rename(os.path.join(self._path, str(key)), - os.path.join(self._path, str(prev + 1))) - finally: - if self._locked: - _unlock_file(f) - finally: - f.close() + if hasattr(os, 'link'): + os.link(os.path.join(self._path, str(key)), + os.path.join(self._path, str(prev + 1))) + os.unlink(os.path.join(self._path, str(key))) + else: + os.rename(os.path.join(self._path, str(key)), + os.path.join(self._path, str(prev + 1))) prev += 1 self._next_key = prev + 1 if len(changes) == 0: |