Python 2.5上的select模块的问题
问题内容:
我在Python 2.5中有一个监听beantalk队列的应用程序。除了我最近购买的MacBook Pro,它在到目前为止我测试过的所有机器上都能正常工作。
在那台计算机上,当我尝试运行它时,出现此错误:
Traceback (most recent call last):
File "jobs.py", line 181, in <module>
Jobs().start()
File "jobs.py", line 154, in start
self.jobQueue = Queue()
File "src/utils/queue.py", line 16, in __init__
self.connection = serverconn.ServerConn(self.server, self.port)
File "src/beanstalk/serverconn.py", line 25, in __init__
self.poller = select.poll()
AttributeError: 'module' object has no attribute 'poll'
serverconn.py具有以下导入:
import socket, select
当我尝试从命令行运行它时,它也会失败:
Python 2.5.1 (r251:54863, Jul 23 2008, 11:00:16)
[GCC 4.0.1 (Apple Inc. build 5465)] 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'
您对可能发生的事情有任何想法吗?
PS:尽管我非常有信心这不是来源问题,但是如果您需要失败来源的某些背景知识,可以在
[http://pastie.org/399342](此
粘贴)上找到它。
更新: 自从第一个答案开始,我就推测Mac OS是否支持select.poll(),但我也有iMac,并且具有完全相同的OS版本,并且工作正常:
2009-02-25 00:27:10,067 - Queue - DEBUG - Connecting to BeansTalk daemon @ localhost:11300
问题答案:
在您的MBP上使用MacPorts版本python
。
Mac OS X支持此功能。苹果股票豹python 2.5.1
没有。
如果尚未下载并安装MacPorts,则需要。仅供参考,我发现Porticus是MacPorts的出色GUI。
这是股票Leopard python与最新的MacPorts python2.5的比较…
Apple的Leopard python(python 2.5.1)- select.poll()
损坏
$ /usr/bin/python
Python 2.5.1 (r251:54863, Jan 13 2009, 10:26:13)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket, select
>>> select.poll()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'poll'
>>>
Macports(Python 2.5.4)- select.poll()
可以使用!
$ /opt/local/bin/python2.5
Python 2.5.4 (r254:67916, Feb 3 2009, 21:40:31)
[GCC 4.0.1 (Apple Inc. build 5488)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket, select
>>> select.poll()
<select.poll object at 0x11128>
>>>