django-debug-toolbar icon indicating copy to clipboard operation
django-debug-toolbar copied to clipboard

RecursionError: maximum recursion depth exceeded while calling a Python object

Open LeoEurope opened this issue 3 years ago • 4 comments

Some time ago I updated to DjDT 3.4.0 from the previous version and instantly ran into issues on certain pages of the Django project (but not others).

The page loading times out and when I check the logs I see:

Error running WSGI application
RecursionError: maximum recursion depth exceeded while calling a Python object

I suspect there is an issue related to DjDT because the problems appeared after the update to DjDT 3.4.0 and when I disable DjDT by setting ‘Debug = False’ I don’t have any issues. Also, there appear to have been similar issues in DjDT years ago.

This is what it says in the DjDT version panel. Django 3.2.13 Python 3.9.5 debug_toolbar Debug Toolbar 3.4.0 django_tables2 Django_Tables2 2.4.1

I’m on the LTS version of Django for a reason and I use Python 3.9.5 because that’s supplied by my hosting provider.

Could this be a regression? Is there anything specific you need to narrow it down?

LeoEurope avatar Jun 01 '22 15:06 LeoEurope

Can you create a reproducible view for us and share that?

tim-schilling avatar Jun 02 '22 13:06 tim-schilling

Can you create a reproducible view for us and share that?

Let me look into that. It's the management dashboard in the backend of an (as of yet) unreleased site so it's not straightforward. I may need to clone it and remove sensitive stuff from the clone. Let me see how much work that would be.

That might take a while so in the mean time, attached are the error log and server log from the start of the crash. I have renamed a directory, virtual environment name, and project name as they are too sensitive at this stage. I have, however, kept the capitalisation in place in case that is part of the problem.

ErrorLog.txt ServerLog.txt

LeoEurope avatar Jun 02 '22 15:06 LeoEurope

This looks a bit as if sys.stderr would emit log events? See here:

2022-06-02 14:54:15   File "/usr/local/lib/python3.9/logging/__init__.py", line 1091, in emit
2022-06-02 14:54:15     self.handleError(record)
2022-06-02 14:54:15 
2022-06-02 14:54:15   File "/usr/local/lib/python3.9/logging/__init__.py", line 1004, in handleError
2022-06-02 14:54:15     sys.stderr.write('--- Logging error ---\n')
2022-06-02 14:54:15 
2022-06-02 14:54:15   File "/usr/local/lib/python3.9/logging/__init__.py", line 1475, in error
2022-06-02 14:54:15     self._log(ERROR, msg, args, **kwargs)

Is it possible that sys.stderr is replaced with an object which logs messages by chance?

matthiask avatar Jun 02 '22 15:06 matthiask

Similarly, in that function that runs sys.stderr.write('--- Logging error ---\n'), it'd be useful to know what the exception was that caused it. Can you use a debugger or add a temporary print statement to print that out before the call to sys.stderr.write?

tim-schilling avatar Jun 02 '22 21:06 tim-schilling

Closing due to lack of response.

tim-schilling avatar Aug 29 '22 00:08 tim-schilling