8000 maximum recursion depth exceeded in comparison · Issue #44 · jmcarp/nplusone · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
maximum recursion depth exceeded in comparison #44
Open
@CosimoRusso

Description

@CosimoRusso

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0