'Create a temporary file to hold the message as it is being transferred.'

def createTempFile(self):

    attr = ((((os.O_RDWR | os.O_CREAT) | os.O_EXCL) | getattr(os, 'O_NOINHERIT', 0)) | getattr(os, 'O_NOFOLLOW', 0))
    tries = 0
    self.fh = (-1)
    while True:
        self.tmpname = os.path.join(self.mbox.path, 'tmp', _generateMaildirName())
        try:
            self.fh = self.osopen(self.tmpname, attr, 384)
            return None
        except OSError:
            tries += 1
            if (tries > 500):
                self.defer.errback(RuntimeError(('Could    not    create    tmp    file    for    %s' % self.mbox.path)))
                self.defer = None
                return None
