def _setblocking(self, block): delay_flag = intmask(_c.fcntl(self.fd, _c.F_GETFL, 0)) if block: delay_flag &= ~_c.O_NONBLOCK else: delay_flag |= _c.O_NONBLOCK _c.fcntl(self.fd, _c.F_SETFL, delay_flag)
def _setblocking(self, block): orig_delay_flag = intmask(_c.fcntl(self.fd, _c.F_GETFL, 0)) if block: delay_flag = orig_delay_flag & ~_c.O_NONBLOCK else: delay_flag = orig_delay_flag | _c.O_NONBLOCK if orig_delay_flag != delay_flag: _c.fcntl(self.fd, _c.F_SETFL, delay_flag)
def _check_fd_mode(fd, reading, writing): flags = intmask(_c.fcntl(fd, _c.F_GETFL, 0)) if flags & _c.O_RDWR: return elif flags & _c.O_WRONLY: if not reading: return else: # O_RDONLY if not writing: return raise OSError(22, "Invalid argument")