[Twisted-Python] Unjelly - recursion limit reached
Jean-Paul Calderone
exarkun at divmod.com
Fri Nov 11 09:46:06 EST 2005
On Fri, 11 Nov 2005 08:26:03 -0600, "David K. Hess" <dhess at verscend.com> wrote:
>
>On Nov 7, 2005, at 8:42 AM, David K. Hess wrote:
>>Bottom line, if all of these things are true, then I'm not sure what is
>>going wrong. Is it possible that jelly is at times walking my object graph
>>(which is interconnected to a certain degree and changes dynamically) in
>>such a way that it has to perform a significant amount of recursion? In
>>other words, maybe this isn't a bug but I just need to increase the
>>runtime recursion limit?
>>
>>FYI, here's a snippet of the exception:
>
>I hate replying to my own post but I'm beginning to believe that recursion
>is the root of the problem and want to focus on it. From the exception
>trace, it looks like it takes on average 3.5 stack frames to unjelly a
>nested object. With a default recursion limit of 1000 stack frames, this
>means that Twisted is limited to transferring an object graph that has a
>depth first traversal through it of length 285 objects (roughly speaking).
>You could of course easily create a linked list of 285 objects to force the
>situation.
Linked list? Hee hee. Crazy.
>
>This is a pretty scary limitation. Is anybody working on a non- recursion
>based version of jelly? Am I going to have to move to Stackless Python?
You can raise the recursion limit. See sys.setrecursionlimit().
Stackless has nothing to do with this. It won't help fix this problem.
The real way to "fix" this is to re-implement the jellying process iteratively. Or, don't use such deeply nested objects.
Jean-Paul
More information about the Twisted-Python
mailing list