Python tornado, 在Linux下, 是实现了Epoll模型, 还是会使用Linux的Epoll ?
PHPz
PHPz 2017-04-18 10:23:12
0
1
807

实际现象

  • 想弄清楚tornado的Epoll

预期现象

上下文环境

  • 产品版本: Tornado最新

  • 操作系统: Linux

  • Python 2.7.x

PHPz
PHPz

学习是最好的投资!

reply all(1)
Peter_Zhu

You can check out the tornadoioloopmodule. There are instructions inside

...
class IOLoop(Configurable):
    """A level-triggered I/O loop.
    We use `epoll` (Linux) or `kqueue` (BSD and Mac OS X) if they
    are available, or else we fall back on select(). If you are
    implementing a system that needs to handle thousands of
    simultaneous connections, you should use a system that supports
    either `epoll` or `kqueue`.
...

inLinux系统中用epoll,BSDMac OS Xkqueue,其他系统中用select.

uses the call of python标准库中的select模块。实际上select模块也只是对系统的select and does not implement it by itself.

If you want to study in depth, you can look at the source code


Thanks @evian for the addition.
python标准库中的select模块是对系统各种I/OEncapsulation of multiplexing solutions.

>>> import platform
>>> platform.linux_distribution()
('Red Hat Enterprise Linux Server', '6.5', 'Santiago')
>>> import select
>>> dir(select)
['EPOLLERR', 'EPOLLET', 'EPOLLHUP', 'EPOLLIN', 'EPOLLMSG', 'EPOLLONESHOT', 'EPOLLOUT',         
'EPOLLPRI', 'EPOLLRDBAND', 'EPOLLRDNORM', 'EPOLLWRBAND', 'EPOLLWRNORM', 'PIPE_BUF', 
'POLLERR', 'POLLHUP', 'POLLIN', 'POLLMSG', 'POLLNVAL', 'POLLOUT', 'POLLPRI', 'POLLRDBAND', 
'POLLRDNORM', 'POLLWRBAND', 'POLLWRNORM', '__doc__', '__file__', '__name__', 
'__package__', 'epoll', 'error', 'poll', 'select']
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template