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

avoid infinite recursion on unkown attribute access in GenericActors. #647

Merged
merged 2 commits into from
Aug 28, 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 docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

import alabaster # noqa

import dramatiq # noqa

sys.path.insert(0, os.path.abspath('../..'))
sys.path.insert(0, os.path.abspath('./'))

import dramatiq # noqa


# -- General configuration ------------------------------------------------

Expand Down
3 changes: 3 additions & 0 deletions dramatiq/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def __new__(metacls, name, bases, attrs):
return clazz

def __getattr__(cls, name):
if "__actor__" not in cls.__dict__:
# avoid infinite recursion on GenericActor
raise AttributeError(f"type object {cls.__name__!r} has no attribute {name!r}")
return getattr(cls.__actor__, name)


Expand Down
5 changes: 5 additions & 0 deletions tests/test_generic_actors.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,8 @@ def perform(self):

# And the actor registry should be called with CustomActor
actor_registry.assert_called_once_with(CustomActor)


def test_getattr_generic_actor():
with pytest.raises(AttributeError):
dramatiq.GenericActor.missing_property
Loading