- 
    Type:Bug 
- 
    Resolution: Done
- 
    Priority:Major - P3 
- 
    Affects Version/s: None
- 
    Component/s: None
- 
    None
- 
    Environment:pymongo 1.9, python 2.6.2, mongod 1.6.3
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
I'm working on a rebalancing-after-failover feature for our application, and so I'm restarting hosts in our 3-host replica set frequently and observing the pymongo failover and our custom code which is reconnecting the slaves as needed. It is possible that I need to handle an edge case in my code to ensure that I don't swap out slave instances in the middle of a transaction, but the bug described here needs to be fixed regardless.
Here's the part of the stack trace in question:
  File "<path>/lib/python2.6/site-packages/pymongo/cursor.py", line 564, in _refresh
    self.__query_spec(), self.__fields))
  File "<path>/lib/python2.6/site-packages/pymongo/cursor.py", line 535, in __send_message
    db.connection.disconnect()
  File "<path>/lib/python2.6/site-packages/pymongo/database.py", line 578, in __call__
    "failing because no such method exists." % self.__name)
TypeError: 'Database' object is not callable. If you meant to call the 'disconnect' method on a 'Connection' object it is failing because no such method exists.
The problem here is that MasterSlaveConnection does not have a disconnect method, so its _getattr_ method is used, which returns a Database instance.