Handling edge case of mongo client missing its messaging methods. No idea why this is happening.

This commit is contained in:
Samuel Clay 2020-12-18 10:11:23 -05:00
parent 865829c58d
commit a316d32038

View file

@ -34,7 +34,9 @@ class MongoDumpMiddleware(object):
def process_celery(self, profiler):
if not self.activated(profiler): return
self._used_msg_ids = []
if not getattr(MongoClient, '_logging', False):
if (not getattr(MongoClient, '_logging', False) and
hasattr(MongoClient, '_send_message_with_response')
hasattr(MongoReplicaSetClient, '_send_message_with_response')):
# save old methods
setattr(MongoClient, '_logging', True)
MongoClient._send_message_with_response = \
@ -114,4 +116,4 @@ def _mongodb_decode_wire_protocol(message):
msg = 'invalid bson'
return { 'op': op, 'collection': collection_name,
'msg_id': msg_id, 'skip': skip, 'limit': limit,
'query': msg }
'query': msg }