python – Pymongo AssertionError:ids不匹配

前端之家收集整理的这篇文章主要介绍了python – Pymongo AssertionError:ids不匹配前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我用:

> MongoDB 1.6.5
> Pymongo 1.9
> Python 2.6.6

我有3种类型的守护进程.第一次从Web加载数据,第二次分析并保存结果,第三组结果.他们都使用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,line 714,in __receive_message_on_socket
    struct.unpack("Failed with AssertionError

任何人都可以告诉这个例子的原因以及如何解决这个问题.

谢谢.

@H_301_21@最佳答案
这可能是与使用gevent协同程序的工作线程有关的线程问题.似乎pymongo连接对象正在读取它没有做出的请求的响应.
原文链接:https://www.f2er.com/python/439102.html

猜你在找的Python相关文章