在Mac OS中不能使用Python select.poll吗? [英] Cannot use Python select.poll in Mac OS?

查看:340
本文介绍了在Mac OS中不能使用Python select.poll吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$ python
Python 2.7.5 (default, Aug 25 2013, 00:04:04) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import select
>>> select.poll
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'poll'

推荐答案

在OSX上使用select.kqueue()代替使用poll.它与Linux上的'epoll'类似,因为您可以更有效地注册可在异步代码中使用的文件描述符/文件系统事件的类型.比轮询更有效.

Instead of using poll, use select.kqueue() on OSX. It's similar to 'epoll' on Linux in that you can more efficiently register for types of file-descriptor / file system events which can be used in asynchronous code. Much more efficient than polling.

否则,等效项只是在一会儿内运行一个阻塞的select.select()True:循环发生某种超时?

Otherwise, the equivalent is just running a blocking select.select() inside a while True: loop with some sort of timeout?

这篇关于在Mac OS中不能使用Python select.poll吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆