lugensa / scorched

Sunburnt offspring solr client
MIT License
27 stars 19 forks source link

Maximum recursion depth exceeded #57

Closed vdnhi closed 3 years ago

vdnhi commented 3 years ago

I am using this library but met an error of maximum recursion depth exceeded in this function. Does anyone have any idea to fix this?

https://github.com/lugensa/scorched/blob/master/scorched/search.py#L146

cc @lujh @mlissner

mlissner commented 3 years ago

Please post a stack trace.

vdnhi commented 3 years ago

@mlissner It here

File "scorched/search.py", line 630, in execute
    ret = self.interface.search(**self.options())
  File "scorched/search.py", line 624, in options
    options = super(SolrSearch, self).options()
  File "scorched/search.py", line 561, in options
    options.update(_attr.options())
  File "scorched/search.py", line 61, in options
    s = self.__unicode_special__()
  File "scorched/search.py", line 211, in __unicode_special__
    self, _ = self.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
    _s, changed = s.normalize()
  File "scorched/search.py", line 153, in normalize
...

normalize function has called 945 times before exceed the recursion depth.

mlissner commented 3 years ago

It might help to post what version you're on. That stack trace doesn't line up with master, but I don't know how far master is away from the latest release.

A case to reproduce would help too.

vdnhi commented 3 years ago

It is version 0.13.0. I can't point out the case it went wrong because of multi complex logic above this call. But when I compared my code I am using, there is no different in implementation of normalize function. Could you help me to figure out the potential reason that make this function exceed the maximum recursion depth?

mlissner commented 3 years ago

My guess is you have a very long list of sub - queries. We need the quiet to be sure. If that's the case, the fix doesn't seem easy to me.

You should also know this library is unmaintained. I wouldn't use it for a new project until it shows real signs of life.

vdnhi commented 3 years ago

Does this function can be rewritten not use recursion but use stack?

mlissner commented 3 years ago

Dunno, but the PR is extremely unlikely to be merged.

icemac commented 3 years ago

I also had this problem when adding a long list of UUIDs to be ignored to a query. I solved it by calling .normalize() on the query object while building the query. This reduced the necessity for scorched to normalize my query and kept it under the recursion limit.