예제 #1
0
def select(rlist, wlist, xlist, timeout=None):
    rlist_norm = _normalize_fd_list(rlist)
    wlist_norm = _normalize_fd_list(wlist)
    xlist_norm = _normalize_fd_list(xlist)
    all_fds = rlist_norm + wlist_norm + xlist_norm
    if not all_fds:
        nfd = 0
    else:
        nfd = max(all_fds) + 1

    rfds = _make_fdset(rlist_norm)
    wfds = _make_fdset(wlist_norm)
    xfds = _make_fdset(xlist_norm)

    if timeout is None:
        timeval = None
    else:
        timeval = _Timeval.new()
        frac, integer = math.modf(timeout)
        timeval.Sec = int(integer)
        timeval.Usec = int(frac * 1000000.0)
    _syscall.invoke(_Select, nfd, rfds, wfds, xfds, timeval)
    return ([
        rlist[i] for i, fd in enumerate(rlist_norm) if _fdset_isset(fd, rfds)
    ], [
        wlist[i] for i, fd in enumerate(wlist_norm) if _fdset_isset(fd, wfds)
    ], [xlist[i] for i, fd in enumerate(xlist_norm) if _fdset_isset(fd, xfds)])
예제 #2
0
파일: select_.py 프로젝트: 0xBADCA7/grumpy
def select(rlist, wlist, xlist, timeout=None):
  rlist_norm = _normalize_fd_list(rlist)
  wlist_norm = _normalize_fd_list(wlist)
  xlist_norm = _normalize_fd_list(xlist)
  all_fds = rlist_norm + wlist_norm + xlist_norm
  if not all_fds:
    nfd = 0
  else:
    nfd = max(all_fds) + 1

  rfds = _make_fdset(rlist_norm)
  wfds = _make_fdset(wlist_norm)
  xfds = _make_fdset(xlist_norm)

  if timeout is None:
    timeval = None
  else:
    timeval = _Timeval.new()
    frac, integer = math.modf(timeout)
    timeval.Sec = int(integer)
    timeval.Usec = int(frac * 1000000.0)
  _syscall.invoke(_Select, nfd, rfds, wfds, xfds, timeval)
  return ([rlist[i] for i, fd in enumerate(rlist_norm) if _fdset_isset(fd, rfds)],
          [wlist[i] for i, fd in enumerate(wlist_norm) if _fdset_isset(fd, wfds)],
          [xlist[i] for i, fd in enumerate(xlist_norm) if _fdset_isset(fd, xfds)])
예제 #3
0
파일: __init__.py 프로젝트: ralic/grumpy3
def waitpid(pid, options):
  status = WaitStatus.new()
  _syscall.invoke(Wait4, pid, status, options, None)
  return pid, _encode_wait_result(status)