gpt4 book ai didi

python - 无法在 Mac OS 中使用 Python select.poll?

转载 作者:太空狗 更新时间:2023-10-29 22:22:44 25 4
gpt4 key购买 nike

$ 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() 代替轮询。它类似于 Linux 上的“epoll”,因为您可以更有效地注册可在异步代码中使用的文件描述符/文件系统事件类型。比轮询更有效。

否则,等价物只是在一段时间内运行一个阻塞的 select.select() 真:循环有某种超时?

关于python - 无法在 Mac OS 中使用 Python select.poll?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19740471/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com