maximum recursion depth exceeded
See original GitHub issueDear all, while extending our schema with a new Node I ran into following exception:
ERROR 2018-02-07 13:28:50,103 exception 29952 123145344159744 Internal Server Error: /graphql
Traceback (most recent call last):
File "/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/site-packages/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/site-packages/django/views/generic/base.py", line 63, in view
self = cls(**initkwargs)
File "/src/graphene-django/graphene_django/views.py", line 70, in __init__
schema = graphene_settings.SCHEMA
File "/src/graphene-django/graphene_django/settings.py", line 116, in __getattr__
val = perform_import(val, attr)
File "/src/graphene-django/graphene_django/settings.py", line 60, in perform_import
return import_from_string(val, setting_name)
File "/src/graphene-django/graphene_django/settings.py", line 74, in import_from_string
module = importlib.import_module(module_path)
File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/Users/dbernardini/Documents/Development/Django/dse_mis/medis/medis/schema.py", line 24, in <module>
schema = graphene.Schema(query=Query, mutation=Mutation)
File "/site-packages/graphene/types/schema.py", line 44, in __init__
self.build_typemap()
File "/site-packages/graphene/types/schema.py", line 105, in build_typemap
self._type_map = TypeMap(initial_types, auto_camelcase=self.auto_camelcase, schema=self)
File "/site-packages/graphene/types/typemap.py", line 66, in __init__
super(TypeMap, self).__init__(types)
File "/site-packages/graphql/type/typemap.py", line 16, in __init__
self.update(reduce(self.reducer, types, OrderedDict()))
File "/site-packages/graphene/types/typemap.py", line 74, in reducer
return self.graphene_reducer(map, type)
File "/site-packages/graphene/types/typemap.py", line 104, in graphene_reducer
return GraphQLTypeMap.reducer(map, internal_type)
File "/site-packages/graphql/type/typemap.py", line 79, in reducer
field_map = type.fields
...
...
File "/site-packages/graphql/type/typemap.py", line 79, in reducer
field_map = type.fields
File "/site-packages/graphql/pyutils/cached_property.py", line 16, in __get__
value = obj.__dict__[self.func.__name__] = self.func(obj)
File "/site-packages/graphql/type/definition.py", line 180, in fields
return define_field_map(self, self._fields)
File "/site-packages/graphql/type/definition.py", line 189, in define_field_map
field_map = field_map()
File "/site-packages/graphene/types/typemap.py", line 247, in construct_fields_for_type
map = self.reducer(map, field.type)
File "/site-packages/graphene/types/typemap.py", line 74, in reducer
return self.graphene_reducer(map, type)
File "/site-packages/graphene/types/typemap.py", line 104, in graphene_reducer
return GraphQLTypeMap.reducer(map, internal_type)
File "/site-packages/graphql/type/typemap.py", line 79, in reducer
field_map = type.fields
File "/site-packages/graphql/pyutils/cached_property.py", line 16, in __get__
value = obj.__dict__[self.func.__name__] = self.func(obj)
File "/site-packages/graphql/type/definition.py", line 180, in fields
return define_field_map(self, self._fields)
File "/site-packages/graphql/type/definition.py", line 189, in define_field_map
field_map = field_map()
File "/site-packages/graphene/types/typemap.py", line 244, in construct_fields_for_type
field = get_field_as(field.get_type(self.schema), _as=Field)
File "/site-packages/graphene/types/dynamic.py", line 21, in get_type
return self.type()
File “/src/graphene-django/graphene_django/converter.py", line 188, in dynamic_type
return Field(_type, description=field.help_text, required=not field.null)
File "/site-packages/graphene/types/field.py", line 39, in __init__
type = NonNull(type)
File "/site-packages/graphene/types/structures.py", line 70, in __init__
super(NonNull, self).__init__(*args, **kwargs)
File "/site-packages/graphene/types/structures.py", line 12, in __init__
super(Structure, self).__init__(*args, **kwargs)
RecursionError: maximum recursion depth exceeded while calling a Python object
Looks to me that there is a recursive call spanning the whole Schema which at some point exceeds the max recursions. I could not find this issue elsewhere and I am trying to understand if it is a problem of our schema or a limit of the current implementation.
For now I extended the max recursions with:
sys.setrecursionlimit(10000)
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
What is the maximum recursion depth in Python, and how to ...
The recursion limit is usually 1000. – Boris Verkhovskiy. Apr 24, 2019 at 7:29. 4.
Read more >Python: Maximum Recursion Depth Exceeded [How to Fix It]
The maximum recursion depth in Python is 1000. To check it, call sys.getrecursionlimit() function. To change it, call sys.setrecursionlimit().
Read more >Python maximum recursion depth exceeded in comparison
The “maximum recursion depth exceeded in comparison” error is raised when you try to execute a function that exceeds Python's built in recursion...
Read more >Python RecursionError: Maximum Recursion Depth Exceeded ...
A Python RecursionError exception is raised when the execution of your program exceeds the recursion limit of the Python interpreter. Two ways ...
Read more >maximum recursion depth exceeded while calling a Python ...
When the interpreter detects that the maximum depth for recursion has reached, it throws the recursionerror ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I see this behavior as well - but I think it has to do with changing the schema while the django server (
manage.py runserver
) is running. When it occurs, I just kill the django server and refresh the page and it works just fine.I only see this during development and not in our production environments - so I am assuming it has to do with the updates while running the django server - but not 100% sure - I could not trace it down. Seems to happen randomly as well.
I have done as you said but I still have the same problem. I have described my configuration in details in this link. Would you please take a look?
Thanks Dani!