Pymongo AssertionError:id 不匹配

发布于 2024-10-14 17:45:06 字数 1839 浏览 4 评论 0原文

我使用:

  • MongoDB 1.6.5
  • Pymongo 1.9
  • Python 2.6.6

我有 3 种类型的守护进程。第一次从网络加载数据,第二次分析并保存结果,第三组结果。他们都使用 Mongodb。 有时,第三个守护进程会抛出许多这样的异常(主要是当数据库中有大量数据时):

Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/gevent-0.13.1-py2.6-linux-x86_64.egg/gevent/greenlet.py", line 405, in run
    result = self._run(*self.args, **self.kwargs)
  File "/data/www/spider/daemon/scripts/mainconverter.py", line 72, in work
    for item in res:
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/cursor.py", line 601, in next
    if len(self.__data) or self._refresh():
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/cursor.py", line 564, in _refresh
    self.__query_spec(), self.__fields))
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/cursor.py", line 521, in __send_message
    **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/connection.py", line 743, in _send_message_with_response
    return self.__send_and_receive(message, sock)
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/connection.py", line 724, in __send_and_receive
    return self.__receive_message_on_socket(1, request_id, sock)
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/connection.py", line 714, in __receive_message_on_socket
    struct.unpack("<i", header[8:12])[0])
AssertionError: ids don't match -561338340 0
<Greenlet at 0x2baa628: <bound method Worker.work of <scripts.mainconverter.Worker object at 0x2ba8450>>> failed with AssertionError

任何人都可以说出导致此异常的原因以及如何解决此问题。

谢谢。

I use:

  • MongoDB 1.6.5
  • Pymongo 1.9
  • Python 2.6.6

I have 3 types of daemons. 1st load data from web, 2nd analyze it and save result, and 3rd group result. All of them working with Mongodb.
At some time 3rd daemon throws many exceptions like this(mostly when there are big amount of data in DB):

Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/gevent-0.13.1-py2.6-linux-x86_64.egg/gevent/greenlet.py", line 405, in run
    result = self._run(*self.args, **self.kwargs)
  File "/data/www/spider/daemon/scripts/mainconverter.py", line 72, in work
    for item in res:
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/cursor.py", line 601, in next
    if len(self.__data) or self._refresh():
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/cursor.py", line 564, in _refresh
    self.__query_spec(), self.__fields))
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/cursor.py", line 521, in __send_message
    **kwargs)
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/connection.py", line 743, in _send_message_with_response
    return self.__send_and_receive(message, sock)
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/connection.py", line 724, in __send_and_receive
    return self.__receive_message_on_socket(1, request_id, sock)
  File "/usr/local/lib/python2.6/dist-packages/pymongo-1.9_-py2.6-linux-x86_64.egg/pymongo/connection.py", line 714, in __receive_message_on_socket
    struct.unpack("<i", header[8:12])[0])
AssertionError: ids don't match -561338340 0
<Greenlet at 0x2baa628: <bound method Worker.work of <scripts.mainconverter.Worker object at 0x2ba8450>>> failed with AssertionError

Can anyone tell what cause this exeption and how to fix this.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゝ偶尔ゞ 2024-10-21 17:45:06

这可能是与您如何将工作线程与 gevent 协程一起使用相关的线程问题。似乎 pymongo 连接对象正在读取它未发出的请求的响应。

This is likely a threading problem related to how you are using worker threads with gevent coroutines. It seems like the pymongo connection object is reading a response for a request it didn't make.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文