def _poll(sockets, timeout):
    cffi_pollitem_list = []
    low_level_to_socket_obj = {}
    for item in sockets:
        low_level_to_socket_obj[item[0].zmq_socket] = item
        cffi_pollitem_list.append(_make_zmq_pollitem(item[0], item[1]))
    items = ffi.new('zmq_pollitem_t[]', cffi_pollitem_list)
    list_length = ffi.cast('int', len(cffi_pollitem_list))
    c_timeout = ffi.cast('long', timeout)
    C.zmq_poll(items, list_length, c_timeout)
    result = []
    for index in range(len(items)):
        if items[index].revents > 0:
            result.append((low_level_to_socket_obj[items[index].socket][0],
                           items[index].revents))
    return result
dataset/ETHPy150Open felipecruz/zmqpy/zmqpy/zmqpy.py/_poll/original