Skip to content Skip to sidebar Skip to footer

Connection Reset By Peer Pymongo

I have some documents which I have to fetch from mongodb and set it to memcache. Here is the code import memcache from pymongo import MongoClient db = mongo_client.job_db.JobParse

Solution 1:

According to the information below for the issue from the pymongo api document here, the exception need to be handled manually.

exception pymongo.errors.AutoReconnect(message='', errors=None)

Raised when a connection to the database is lost and an attempt to auto-reconnect will be made.

In order to auto-reconnect you must handle this exception, recognizing that the operation which caused it has not necessarily succeeded. Future operations will attempt to open a new connection to the database (and will continue to raise this exception until the first successful connection is made).

I searched some existing solution for the issue, please see below.

  1. A code snippet from here for gracefully handling the PyMongo AutoReconnect exception.
  2. Using a middleware named MongoDBProxy to automatically handle AutoReconnect exception.

Hope it helps.

Post a Comment for "Connection Reset By Peer Pymongo"