fix: exceptions.OSError might not have attribute EEXIST defined

Since this is used in an except calse, we first don't mask the real cause and
raise the original error.

Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
Nicolas Sebrecht 2016-02-19 12:33:57 +01:00
parent 36165e391f
commit 36375daee6

View File

@ -292,7 +292,8 @@ class MaildirFolder(BaseFolder):
that was created."""
tmpname = os.path.join('tmp', filename)
# open file and write it out
# Open file and write it out.
# XXX: why do we need to loop 7 times?
tries = 7
while tries:
tries = tries - 1
@ -301,6 +302,8 @@ class MaildirFolder(BaseFolder):
os.O_EXCL|os.O_CREAT|os.O_WRONLY, 0o666)
break
except OSError as e:
if not hasattr(e, 'EEXIST'):
raise
if e.errno == e.EEXIST:
if tries:
time.sleep(0.23)