猿问

关于 epoll 的小小疑问, epoll 在等待事件的过程中会阻塞么

最近在看tornado的源码,有个RT的疑问

try:
    event_pairs = self._impl.poll(poll_timeout)
    except Exception as e:
    # Depending on python version and IOLoop implementation,
    # different exception types may be thrown and there are
    # two ways EINTR might be signaled:
    # * e.errno == errno.EINTR
    # * e.args is like (errno.EINTR, 'Interrupted system call')
        if errno_from_exception(e) == errno.EINTR:
            continue
        else:
            raise

在调用poll方法等待事件的过程中epoll是马上返回还是至少有一个事件后才返回

DIEA
浏览 589回答 2
2回答

缥缈止盈

epoll是至少有一个事件才返回。在有事件之前是阻塞住的

牛魔王的故事

当然会阻塞啊 一般用法 while 1: fd.poll()不阻塞不是死循环了? 当然有时候根据需要也有用非阻塞的(把超时设置成0),相当于是在查询系统事件
随时随地看视频慕课网APP

相关分类

Python
我要回答