Skip to content

Commit

Permalink
Merge pull request #23 from openedx/umar/add-pymongo4-compatibility
Browse files Browse the repository at this point in the history
Add pymongo4 compatibility
  • Loading branch information
mumarkhan999 authored Jul 8, 2024
2 parents fa8607d + 8967f96 commit 297211a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions mongodb_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __getitem__(self, key):
Otherwise just return the attribute.
"""
item = self.proxied_object[key]
if hasattr(item, '__call__'):
if hasattr(item, '__call__') or isinstance(item, pymongo.database.Database):
return MongoProxy(item, self.wait_time)
return item

Expand All @@ -103,7 +103,7 @@ def __getattr__(self, key):
that handles AutoReconnect exceptions. Otherwise wrap it in a MongoProxy object.
"""
attr = getattr(self.proxied_object, key)
if hasattr(attr, '__call__'):
if hasattr(attr, '__call__') or isinstance(attr, pymongo.database.Database):
attributes_for_class = self.methods_needing_retry.get(self.proxied_object.__class__, [])
if key in attributes_for_class:
return autoretry_read(self.wait_time)(attr)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def is_requirement(line):
setup(
name='openedx-mongodbproxy',
py_modules=['mongodb_proxy'],
version='0.2.0',
version='0.2.1',
description='Proxy around MongoDB connection that automatically handles AutoReconnect exceptions.',
author='Gustav Arngarden',
long_description=LONG_DESCRIPTION,
Expand Down

0 comments on commit 297211a

Please sign in to comment.