最近在看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是马上返回还是至少有一个事件后才返回
![]() | 1 Missex 2015-01-04 17:23:40 +08:00 ![]() epoll是有事件的时候或者超时才返回。 |
![]() | 2 aszxqw 2015-01-04 17:29:11 +08:00 ![]() 会。 |
![]() | 3 dndx 2015-01-04 17:56:12 +08:00 ![]() 可以阻塞也可以不阻塞。如果 timeout 是 -1,那么会一直等待直到最少一个 vent available 或者被信号中断。 如果 timeout 是 0,那么会立刻返回,即使没有可用 event。 如果 timeout 是其他数字,那么会最多等待这么多秒,除非有至少一个 event available 或者被信号中断。 http://man7.org/linux/man-pages/man2/epoll_wait.2.html |
4 zenliver 2015-01-04 19:10:19 +08:00 ![]() tornado的会, epoll自身可以立刻返回, 参考man |
![]() | 5 inevermore 2015-01-04 20:14:57 +08:00 ![]() 常规用法是会的。 而且用epoll的目的是,其他代码不阻塞,仅仅在epoll调用处阻塞。 |