def _make_atomic_write(self, result, raw): # Our return value from _do_open_raw is always a new # object that we own, so we're always free to change # the class. assert result is not raw or self._raw_object_is_new(raw) if result.__class__ is GreenFileDescriptorIO: result.__class__ = GreenFileDescriptorIOWriteall else: result = OpenDescriptor._make_atomic_write(self, result, raw) return result
def _do_open_raw(self): if self.is_fd(): fileio = GreenFileDescriptorIO(self._fobj, self, closefd=self.closefd) else: # Either an existing file object or a path string (which # we open to get a file object). In either case, the other object # owns the descriptor and we must not close it. closefd = False raw = OpenDescriptor._do_open_raw(self) fileno = raw.fileno() fileio = GreenFileDescriptorIO(fileno, self, closefd=closefd) fileio._keep_alive = raw return fileio
def _do_open_raw(self): if self.is_fd(): fileio = GreenFileDescriptorIO(self._fobj, self, closefd=self.closefd) else: # Either an existing file object or a path string (which # we open to get a file object). In either case, the other object # owns the descriptor and we must not close it. closefd = False raw = OpenDescriptor._do_open_raw(self) fileno = raw.fileno() fileio = GreenFileDescriptorIO(fileno, self, closefd=closefd) fileio._keep_alive = raw # We can usually do better for a name, though. try: fileio.name = raw.name except AttributeError: del fileio.name return fileio
def _makeOne(self, *args, **kwargs): return OpenDescriptor(*args, **kwargs)