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

maximum recursion depth exceeded in comparison #44

Open
CosimoRusso opened this issue Jun 27, 2022 · 1 comment
Open

maximum recursion depth exceeded in comparison #44

CosimoRusso opened this issue Jun 27, 2022 · 1 comment

Comments

@CosimoRusso
Copy link

There are some cases when in the function signalify_fetch_all the decorator is called on the already decorated function queryset._fetch_all, causing a recursion depth exception if a fetch all query is invoked many times. This also happens if the query is not actually executed but its cached result is used. The issue can be reproduced through the following Django test:

class TestTheIssue(TestCase):
    def test_n_plus_one_wrapper_error(self):
        out = []
        # MyModelA has many MyModelB, the relationship is represented adding a 
        # models.ForeignKey field on model B with related name 'my_model_bs'
        qs = MyModelA.objects.all().prefetch_related('my_model_bs').first()
        # Execute this query N times, with N any number that is bigger than the recursion limit, 
        # in my case it is sys.getrecursionlimit() = 1000 
        for i in range(2000):  
            tmp = qs.my_model_bs.all()
            out.append(tmp.first())

        print(out[-1])

Details

nplusone version: 1.0.0
Django version: 3.2.13

environment: python:3.8.9-slim-buster image for Docker

@johnnymetz
Copy link

I'm also running into this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants