0

I have these code here http://pastebin.com/YHpZQ9Z9

After a few interval randomly, the error pops out and I cannot debug on what is causing the problem, can any professional help me ?

I encounter these error:

Traceback (most recent call last):

run()    

weather_Connection(intervalone)

response = get_response(conn, url)

return json.loads(data)

return _default_decoder.decode(s)

obj, end = self.raw_decode(s)

return self.scan_once(s, idx=_w(s, idx).end())

return _scan_once(string, idx)

raise JSONDecodeError(errmsg, string, idx)
simplejson.scanner.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

1 Answer 1

1

Your url is probably returning an invalid json, it returns 502 status intermitttently

"https://api.forecast.io/forecast/59ff8cb7661d231f2967c2663c0a3bdc/1.37871,103.848808"

Sign up to request clarification or add additional context in comments.

5 Comments

Any idea how can i fix this ? The website is sometimes unstable and is returning invalid key, but after a few refreshes it work. How can I counter measure this ?
You can use memcached to store valid responses for few minutes, the forecasts do not change in that time, and that would make your app faster as ewll.
Instead of httplib I prefer to use requests. docs.python-requests.org/en/latest
I don't get it when <------- # HOST NOT USED HERE ? How to put host there?
@Helpme, that code was correct, ignore my comment. The only error is 502 being returned from the api, you have to check the status and proceed accordingly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.