Python tornado, 在Linux下, 是實(shí)現(xiàn)了Epoll模型, 還是會使用Linux的Epoll ?
問題描述
實(shí)際現(xiàn)象想弄清楚tornado的Epoll
預(yù)期現(xiàn)象上下文環(huán)境產(chǎn)品版本: Tornado最新
操作系統(tǒng): Linux
Python 2.7.x
問題解答
回答1:可以去看tornado的ioloop模塊。里面有說明
...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`....
在Linux系統(tǒng)中用epoll,BSD或Mac OS X用kqueue,其他系統(tǒng)中用select。
使用的是python標(biāo)準(zhǔn)庫中的select模塊。實(shí)際上select模塊也只是對系統(tǒng)的select的調(diào)用,并沒有自己實(shí)現(xiàn)。
想深入研究的話可以看源碼
感謝 @依云 的補(bǔ)充。python標(biāo)準(zhǔn)庫中的select模塊是對系統(tǒng)各種I/O復(fù)用方案的封裝。
>>> 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’]
相關(guān)文章:
