human
I wrote the below code

    if ((not rlist) and (not wlist) and (not xlist)):
        if timeout:
            time.sleep(timeout)
        return ([], [], [])
    state_map = {}
    (rlist_out, wlist_out, xlist_out) = ([], [], [])
    def _SetState(request, sock, event):
        socket_descriptor = sock._SocketDescriptor()
        state = state_map.setdefault(socket_descriptor, {'observed_events': 0})
        if (((event == POLLIN) and sock._shutdown_read) or ((event == POLLOUT) and sock._shutdown_write)):
            state['observed_events'] |= event
            request.set_timeout_seconds(0.0)
            return
        poll_event = state.get('poll_event')
        if (not poll_event):
            poll_event = request.add_events()
            poll_event.set_socket_descriptor(socket_descriptor)
            poll_event.set_observed_events(0)
            state['poll_event'] = poll_event
        poll_event.set_requested_events((poll_event.requested_events() | event))
    request = remote_socket_service_pb.PollRequest()
    if (timeout is not None):
        request.set_timeout_seconds(timeout)
    for value in rlist:
        _SetState(request, _GetSocket(value), POLLIN)
    for value in wlist:
        _SetState(request, _GetSocket(value), POLLOUT)
    if request.events_size():
        reply = remote_socket_service_pb.PollReply()
        try:
            apiproxy_stub_map.MakeSyncCall('remote_socket', 'Poll', request, reply)
        except apiproxy_errors.ApplicationError as e:
            raise _SystemExceptionFromAppError(e)
        for event in reply.events_list():
            state_map[event.socket_descriptor()]['observed_events'] |= event.observed_events()
    for value in rlist:
        state = state_map[_GetSocket(value)._SocketDescriptor()]
        if (state['observed_events'] & POLLIN):
            rlist_out.append(value)
    for value in wlist:
        state = state_map[_GetSocket(value)._SocketDescriptor()]
        if (state['observed_events'] & POLLOUT):
            wlist_out.append(value)
    return (rlist_out, wlist_out, xlist_out)

What's a good function header?
 Here's a good function header?
assistant
#Here's a good function header.

def select(rlist, wlist, xlist, timeout=None):