回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我和gevent一起使用redispy和redish,我有自己的类EventBot,它继承了Greenlet。在</p>
<p>在这个类的<code>__init__</code>方法中,我使用</p>
<pre class="lang-py prettyprint-override"><code>self._redis = Client(serializer=serialization.JSON(), **self.REDIS_CONFIG)
</code></pre>
<p>有时当我试图运行脚本时,它抛出<code>SystemError: NULL result without error in PyObject_Call</code>,但有时它正常启动。我还尝试将redis初始化移动到<code>_run()</code>方法,但没有起到任何作用。在</p>
<p>这是我使用的简化类:</p>
^{pr2}$
<p>以下是完整的回溯:</p>
<pre><code>Traceback (most recent call last):
File "start.py", line 15, in <module>
bot = EventBot('marie@xxx.com', 'XXXpasswordXXX')
File "/tmp/sandbox/gmarie/gmarie/marie/eventbot.py", line 41, in __init__
self._questions = self._redis[QUESTIONS_KEY]
File "/tmp/sandbox/gmarie/venv/lib/python2.7/site-packages/redish/client.py", line 196, in __getitem__
value = self.api.get(name)
File "/tmp/sandbox/gmarie/venv/lib/python2.7/site-packages/redis/client.py", line 551, in get
return self.execute_command('GET', name)
File "/tmp/sandbox/gmarie/venv/lib/python2.7/site-packages/redis/client.py", line 360, in execute_command
connection.send_command(*args)
File "/tmp/sandbox/gmarie/venv/lib/python2.7/site-packages/redis/connection.py", line 301, in send_command
self.send_packed_command(self.pack_command(*args))
File "/tmp/sandbox/gmarie/venv/lib/python2.7/site-packages/redis/connection.py", line 283, in send_packed_command
self.connect()
File "/tmp/sandbox/gmarie/venv/lib/python2.7/site-packages/redis/connection.py", line 228, in connect
sock = self._connect()
File "/tmp/sandbox/gmarie/venv/lib/python2.7/site-packages/redis/connection.py", line 240, in _connect
sock.connect((self.host, self.port))
File "/tmp/sandbox/gmarie/venv/lib/python2.7/site-packages/gevent/socket.py", line 376, in connect
wait_readwrite(sock.fileno(), event=self._rw_event)
File "/tmp/sandbox/gmarie/venv/lib/python2.7/site-packages/gevent/socket.py", line 215, in wait_readwrite
switch_result = get_hub().switch()
File "/tmp/sandbox/gmarie/venv/lib/python2.7/site-packages/gevent/hub.py", line 164, in switch
return greenlet.switch(self)
SystemError: NULL result without error in PyObject_Call
Exception KeyError: KeyError(21246672,) in <module 'threading' from '/usr/lib64/python2.7/threading.py'> ignored
</code></pre>
<p>任何帮助都将不胜感激。在</p>
<hr/>
<p><strong>编辑:</strong></p>
<p>当使用<code>gevent</code>和<code>greenlet</code>系统包时,问题似乎得到了解决(在ArchLinux中,<code>python2-gevent</code>和{<cd7>}),但根据它们的PKGBUILD,没有进行额外的修补。(<a href="https://projects.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/python2-gevent" rel="nofollow">gevent</a>,<a href="https://projects.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/python2-greenlet" rel="nofollow">greenlet</a>)有人能解释一下使用pip安装的错误吗?在</p>