【发布时间】:2014-11-14 06:52:25
【问题描述】:
上下文:
我正在尝试使用 pypy 解释器启动石墨。
错误:
启动石墨(*)导致
ImportError: cannot import name 'threadpool',
即使启动 python (pypy) 解释器并输入 from twisted.python import threadpool 也可以。
完整的堆栈跟踪:
15/09/2014 13:29:09 :: File "app_main.py", line 75, in run_toplevel
15/09/2014 13:29:09 :: File "/opt/graphite/bin/carbon-cache.py", line 30, in <module>
15/09/2014 13:29:09 :: run_twistd_plugin(__file__)
15/09/2014 13:29:09 :: File "/opt/graphite/lib/carbon/util.py", line 93, in run_twistd_plugin
15/09/2014 13:29:09 :: runApp(config)
15/09/2014 13:29:09 :: File "/home/vagrant/test2/site-packages/twisted/scripts/twistd.py", line 23, in runApp
15/09/2014 13:29:09 :: File "/home/vagrant/test2/site-packages/twisted/application/app.py", line 380, in run
15/09/2014 13:29:09 :: File "/home/vagrant/test2/site-packages/twisted/scripts/_twistd_unix.py", line 193, in postApplication
15/09/2014 13:29:09 :: File "/home/vagrant/test2/site-packages/twisted/scripts/_twistd_unix.py", line 390, in startApplication
15/09/2014 13:29:09 :: File "/home/vagrant/test2/site-packages/twisted/application/app.py", line 658, in startApplication
15/09/2014 13:29:09 :: File "/home/vagrant/test2/site-packages/twisted/application/service.py", line 282, in startService
15/09/2014 13:29:09 :: File "/home/vagrant/test2/site-packages/twisted/application/service.py", line 282, in startService
15/09/2014 13:29:09 :: File "/opt/graphite/lib/carbon/writer.py", line 191, in startService
15/09/2014 13:29:09 :: reactor.callInThread(writeForever)
15/09/2014 13:29:09 :: File "/home/vagrant/test2/site-packages/twisted/internet/base.py", line 997, in callInThread
15/09/2014 13:29:09 :: File "/home/vagrant/test2/site-packages/twisted/internet/base.py", line 989, in getThreadPool
15/09/2014 13:29:09 :: File "/home/vagrant/test2/site-packages/twisted/internet/base.py", line 954, in _initThreadPool
15/09/2014 13:29:09 :: ImportError: cannot import name 'threadpool'
我在 centos 6.5 上使用 pypy (2.3.1-linux_x86_64-portable) 并运行 pip 来安装twisted、whisper(并应用了额外的patch)
(*) test2/bin/python /opt/graphite/bin/carbon-cache.py --instance=a start
编辑:
virtualenv 被称为 test2。
test2/site-packages/twisted/python/threadpool.py{,c} 显示twisted 有线程池
test2/bin/pypy --info显示[usemodules] thread = True'twisted.python.threadpool' in sys.modules在导入失败之前返回 false
编辑2:
在调用堆栈的前面添加from twisted.python import threadpool(例如在 /opt/graphite/lib/carbon/util.py 中)可以使石墨工作。
【问题讨论】:
标签: twisted python-import graphite pypy