python中select模块_Python 2.5上的select模块的问题

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

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'

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 "", line 1, in

AttributeError: 'module' object has no attribute 'poll'

Do you have any idea on what can be happening?

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).

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

解决方案

use the MacPorts version of python on your MBP.

Mac OS X supports this. Apple stock Leopard python 2.5.1 does not.

you will want to download and install MacPorts if you have not already. FYI, I find Porticus to be an excellent GUI around MacPorts.

here is a comparison of stock Leopard python vs. latest MacPorts python2.5...

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 "", line 1, in

AttributeError: 'module' object has no attribute '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()

>>>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值