Python 2.5上的select模块的问题 [英] Problems on select module on Python 2.5
问题描述
我在Python 2.5中有一个监听beantalk队列的应用程序.除了我最近购买的MacBook Pro,它在到目前为止我测试过的所有机器上都可以正常工作.
I have an application in Python 2.5 that listens to a beanstalk queue. It works fine on all machines I tested so far, except from my newly acquired MacBook Pro.
在那台计算机上,当我尝试运行它时,出现此错误:
On that computer, when I try to run it I get this error:
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具有以下导入:
The serverconn.py has the following imports:
import socket, select
当我尝试从命令行运行它时,它也会失败:
And when I try to run it from command line, it fails as well:
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'
您对可能发生的事情有任何了解吗?
Do you have any idea on what can be happening?
PS:即使我非常确定这不是源问题,但是如果您需要失败源的某些背景知识,也可以在[ http://pastie.org/399342](此粘贴).
PS: Even though I am pretty confident it's not a source problem, if you need some background on the source that's failing, it's available at [http://pastie.org/399342](this pastie).
已更新:因为我得到的第一个答案推测Mac OS上是否支持select.poll(),但我也有iMac,并且操作系统版本完全相同,因此工作正常:
Updated: since the first answer I got speculates whether select.poll() is or not supported on Mac OS, but I have an iMac too and with the exact same OS version and it works fine:
2009-02-25 00:27:10,067 - Queue - DEBUG - Connecting to BeansTalk daemon @ localhost:11300
推荐答案
使用 MacPorts 版本的python
在您的MBP上.
use the MacPorts version of python
on your MBP.
Mac OS X支持此功能.苹果股票Leopard python 2.5.1
没有.
Mac OS X supports this. Apple stock Leopard python 2.5.1
does not.
如果尚未下载并安装MacPorts,则需要.仅供参考,我发现 Porticus 是围绕MacPorts的出色GUI.
you will want to download and install MacPorts if you have not already. FYI, I find Porticus to be an excellent GUI around MacPorts.
这是股票Leopard python与最新的MacPorts python2.5的比较...
here is a comparison of stock Leopard python vs. latest MacPorts python2.5...
Apple的豹纹python(python 2.5.1)- select.poll()
损坏
Leopard python from Apple (python 2.5.1) - select.poll()
broken
$ /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()
可以使用!
Macports (python 2.5.4) - select.poll()
works!
$ /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>
>>>
这篇关于Python 2.5上的select模块的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!