def _call_select(space, iwtd_w, owtd_w, ewtd_w, ll_inl, ll_outl, ll_errl, ll_timeval, timeout): fdlistin = fdlistout = fdlisterr = None nfds = -1 if ll_inl: fdlistin, nfds = _build_fd_set(space, iwtd_w, ll_inl, nfds) if ll_outl: fdlistout, nfds = _build_fd_set(space, owtd_w, ll_outl, nfds) if ll_errl: fdlisterr, nfds = _build_fd_set(space, ewtd_w, ll_errl, nfds) if ll_timeval: end_time = timeutils.monotonic(space) + timeout else: end_time = 0.0 while True: if ll_timeval: i = int(timeout) rffi.setintfield(ll_timeval, 'c_tv_sec', i) rffi.setintfield(ll_timeval, 'c_tv_usec', int((timeout - i) * 1000000)) res = _c.select(nfds + 1, ll_inl, ll_outl, ll_errl, ll_timeval) if res >= 0: break # normal path err = _c.geterrno() if err != errno.EINTR: msg = _c.socket_strerror_unicode(err) raise OperationError( space.w_OSError, space.newtuple([space.newint(err), space.newunicode(msg)])) # got EINTR, automatic retry space.getexecutioncontext().checksignals() if timeout > 0.0: timeout = end_time - timeutils.monotonic(space) if timeout < 0.0: timeout = 0.0 resin_w = [] resout_w = [] reserr_w = [] if res > 0: if fdlistin is not None: _unbuild_fd_set(space, iwtd_w, fdlistin, ll_inl, resin_w) if fdlistout is not None: _unbuild_fd_set(space, owtd_w, fdlistout, ll_outl, resout_w) if fdlisterr is not None: _unbuild_fd_set(space, ewtd_w, fdlisterr, ll_errl, reserr_w) return space.newtuple([ space.newlist(resin_w), space.newlist(resout_w), space.newlist(reserr_w) ])
def get_msg_unicode(self): return _c.socket_strerror_unicode(self.errno)