Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pymongo4 compatibility #23

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading