Alexandre
Alexandre

Reputation: 2111

Heroku + Django + Piston

I'm using Heroku with Django and using Piston for API stuff.

We migrated from plain Amazon EC2 to Heroku. Everything works (every aspect of the website) except for some of the API calls.

When I run an API call to get a list of objects (trees) that user has, I get the following:

RuntimeError at /api/tree.json
maximum recursion depth exceeded while calling a Python object

Anyone have any ideas of why this could be? Thanks in advance, I'd really appreciate any hints/advice!

Upvotes: 0

Views: 324

Answers (2)

Alexandre
Alexandre

Reputation: 2111

This was a tricky problem to debug. It turned out that the problem was that Heroku dynos can't see each other's temp directory. This meant that after migrating to Heroku even though we wrote a file to the temporary directory, when we scheduled a task to process that file, the file would mysteriously not be there. We solved this by writing the files directly to S3 (instead of using the temporary directory).

Also, Piston's new version has a database schema change, so make sure that that is updating correctly!

Upvotes: 1

luke14free
luke14free

Reputation: 2539

This basically mean that your three is a bit too structured and that the function that decodes it (which is recursive) exceeds the maximum depth limit for recursive calls (for example an example of recursion depth = 3 is a function calling a function, that calls another function, that calls another function). If you are using a custom algorithm to decode json simply make sure to swith from a recursive approach to a iterative approach (it can be done with many algorithms implementing a cue). Try to see what is your limit of recursive operations:

>>> import sys
>>> sys.getrecursionlimit()
1000 #on my mac but this is system dependent.

And if you are not satisfied with it change it as follows:

>>> sys.setrecursionlimit(...)

Avoid setting to high number because they can crash your system; and I bet that heroku limits the maximum depth recursion somehow.

Upvotes: 0

Related Questions