~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/local.py

  • Committer: INADA Naoki
  • Date: 2010-02-19 18:33:53 UTC
  • mto: (4634.141.1 2.0-integration)
  • mto: This revision was merged to the branch mainline in revision 5075.
  • Revision ID: songofacandy@gmail.com-20100219183353-93t4qeo7q8i6jzcg
Avoids child process inherits file handles on win32. by using os.fdopen and os.open with O_NOINHERIT instead of builtin open.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
from bzrlib.transport import Transport, Server
43
43
 
44
44
 
45
 
_append_flags = os.O_CREAT | os.O_APPEND | os.O_WRONLY | osutils.O_BINARY
46
 
_put_non_atomic_flags = os.O_CREAT | os.O_TRUNC | os.O_WRONLY | osutils.O_BINARY
 
45
_append_flags = os.O_CREAT | os.O_APPEND | os.O_WRONLY | osutils.O_BINARY | osutils.O_NOINHERIT
 
46
_put_non_atomic_flags = os.O_CREAT | os.O_TRUNC | os.O_WRONLY | osutils.O_BINARY | osutils.O_NOINHERIT
 
47
_get_flags = os.O_RDONLY | osutils.O_BINARY | osutils.O_NOINHERIT
 
48
_write_stream_flags = _put_non_atomic_flags
47
49
 
48
50
 
49
51
class LocalTransport(Transport):
160
162
            transport._file_streams[canonical_url].flush()
161
163
        try:
162
164
            path = self._abspath(relpath)
163
 
            return open(path, 'rb')
 
165
            return os.fdopen(os.open(path, _get_flags), 'rb')
164
166
        except (IOError, OSError),e:
165
167
            if e.errno == errno.EISDIR:
166
168
                return LateReadError(relpath)
329
331
        # initialise the file
330
332
        self.put_bytes_non_atomic(relpath, "", mode=mode)
331
333
        abspath = self._abspath(relpath)
332
 
        handle = open(abspath, 'wb')
 
334
        handle = os.fdopen(os.open(abspath, _write_stream_flags), 'wb')
333
335
        if mode is not None:
334
336
            self._check_mode_and_size(abspath, handle.fileno(), mode)
335
337
        transport._file_streams[self.abspath(relpath)] = handle