ebachelet / pyLIMA

GNU General Public License v3.0
31 stars 8 forks source link

Rare and random HTTP 503 errors from JPL Horizon on parallax models #78

Open ketozhang opened 8 months ago

ketozhang commented 8 months ago

Less than 1% of the times when I am running a model with parallax (letting pyLIMA fetch ephemerides for me), I get errors from JPL Horizon.

The culprit might be here where too many queries are made to JPL: https://github.com/ebachelet/pyLIMA/blob/92b4f475214b693f8906b4f2ab16e2f69c2fd8d5/pyLIMA/parallax/JPL_ephemerides.py#L78-L110

However, it is also likely because I am running many models at the same time overloading the Horizon servers.


A fix that satisfies both issue is to add a "retry with backoff" algorithm (try to query again after waiting an exponentially increasing time)

It should be added to either here... https://github.com/ebachelet/pyLIMA/blob/92b4f475214b693f8906b4f2ab16e2f69c2fd8d5/pyLIMA/parallax/parallax.py#L181-L184

or as part of JPL_ephemerides.horizons_API itself.

ketozhang commented 8 months ago

I can contribute to this sometime soon.

My idea is to add one of these two libraries


One thing to discuss is whether this is the right place to fix this or should the user handle this themselves (by handling whenever they see a requests.exceptions.HTTPError from pyLIMA)