47
48
__slots__ = ['tmpfilename', 'realfilename', '_fd']
49
50
def __init__(self, filename, mode='wb', new_mode=None):
58
self.tmpfilename = '%s.%d.%s.%s.tmp' % (filename, _pid, _hostname,
56
61
self.realfilename = filename
58
63
flags = os.O_EXCL | os.O_CREAT | os.O_WRONLY
60
65
flags |= osutils.O_BINARY
67
74
# Use a low level fd operation to avoid chmodding later.
68
75
# This may not succeed, but it should help most of the time
69
76
self._fd = os.open(self.tmpfilename, flags, local_mode)