Skip to content

Commit

Permalink
Merge pull request #229 from IlyaSkriblovsky/distinct-autoreconnect-i…
Browse files Browse the repository at this point in the history
…nstances

Do not reuse exception instances
  • Loading branch information
psi29a committed Mar 16, 2018
2 parents af42461 + c45caae commit c1e08b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/source/NEWS.rst
Expand Up @@ -11,6 +11,7 @@ Bugfixes
^^^^^^^^

- Fixed compatibility of `Collection.aggregate()` with PyMongo 3.6
- AutoReconnect exceptions may give invalid stack traces when not handled

Features
^^^^^^^^
Expand Down
6 changes: 2 additions & 4 deletions txmongo/protocol.py
Expand Up @@ -323,16 +323,14 @@ def connectionLost(self, reason=connectionDone):
# too late.
self.factory.setInstance(None, reason)

auto_reconnect = AutoReconnect("TxMongo lost connection to MongoDB.")

if self.__deferreds:
deferreds, self.__deferreds = self.__deferreds, {}
for df in deferreds.values():
df.errback(auto_reconnect)
df.errback(AutoReconnect("TxMongo lost connection to MongoDB."))
deferreds, self.__connection_ready = self.__connection_ready, []
if deferreds:
for df in deferreds:
df.errback(auto_reconnect)
df.errback(AutoReconnect("TxMongo lost connection to MongoDB."))

protocol.Protocol.connectionLost(self, reason)

Expand Down

0 comments on commit c1e08b7

Please sign in to comment.