mlco2 / mlco2/codecarbon

Unable to access geographical location through primary API

Open
#854 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
1.9k
Forks
323
Avg merge
1d 12h
Merged PRs (30d)
12

Description

I keep getting this error sometimes. Seems random. Should there be a retry?
For example, I'm starting 8 processes in parallel, each creating an EmissionsTracker. I'm even timing them to start slightly apart (within a random amount 0-3 seconds). However, for 6 of 8 processes, I get this error

[codecarbon WARNING @ 19:46:23] Unable to access geographical location through primary API. Will resort to using the backup API - Exception : HTTPSConnectionPool(host='get.geojs.io', port=443): Read timed out. (read timeout=0.5) - url=https://get.geojs.io/v1/ip/geo.json [get.geojs.io]     
[codecarbon WARNING @ 19:46:23] Unable to access geographical location. Using 'Canada' as the default value - Exception : 'country' - url=https://get.geojs.io/v1/ip/geo.json [get.geojs.io]  

Note, using a random sleep of up to 10 sec between processes seems to help. It only cased 2 of 8 geojs API calls to fail.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at EmissionsTracker initialization and trace the geographical-location lookup that calls get.geojs.io, then reproduce the parallel-process scenario described in the issue. Compare the primary and backup API failure paths; done should mean transient lookup failures are handled reliably without incorrectly falling back to the default country.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.