pymongo.errors.BulkWriteError没有被捕获

时间:2019-01-15 12:54:24

标签: python-3.x pymongo-3.x

我的代码正常工作,但是有一天才开始提出BulkWriteError。但是我不明白为什么会这样,因为我在except中捕获了错误。

我正在使用pymongo 3.2.1,并将Python从3.6.6升级到3.6.7

我认为升级Python不应成为问题,我前段时间发现了此错误,并在删除日志时修复了它,但它甚至没有任何意义。

这是我的代码

try:
     yield user_collection.insert_many(users)
except errors.BulkWriteError as e:
     process(e)
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/txmongo/protocol.py", line 308, in handle
     handler(request)
   File "/app/.heroku/python/lib/python3.6/site-packages/txmongo/protocol.py", line 437, in handle_REPLY
     df.callback(request)
   File "/app/.heroku/python/lib/python3.6/site-packages/twisted/internet/defer.py", line 393, in callback
     self._startRunCallbacks(result)
   File "/app/.heroku/python/lib/python3.6/site-packages/twisted/internet/defer.py", line 501, in _startRunCallbacks
     self._runCallbacks()
 --- <exception caught here> ---
   File "/app/.heroku/python/lib/python3.6/site-packages/twisted/internet/defer.py", line 588, in _runCallbacks
     current.result = callback(current.result, *args, **kw)
   File "/app/.heroku/python/lib/python3.6/site-packages/txmongo/collection.py", line 1383, in on_all_done
     raise BulkWriteError(full_result)
 pymongo.errors.BulkWriteError: batch op errors occurred

0 个答案:

没有答案