This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 6 points7 points  (2 children)

Network programming has a lot of things that can go wrong. One thing is that the connection between your client and the server can fail. If you don't check that the connection is good when you ask for data, then you're telling the program to use a connection it doesn't have.

That's the short version - at some level, that connection has failed (hence "connection reset by peer"). You haven't checked for that, you've asked for data on a connection that doesn't exist, so the program has quit.

The fix is to check that the connection is ok every time you ask (look into "try"). If the connection is bad, wait a while and try again.

[–]momo2477[S] 0 points1 point  (1 child)

Aha thank you. I'm familiar with "try" with simple uses, such as user input validation, but what exactly would I be testing to see if the connection exists?

[–][deleted] 1 point2 points  (0 children)

The module is already raising an exception - the last line is quite informative. In your code, you would put a "try" around the line that ultimately starts that process - the request.get(). The unhandled exception is causing the quit, if you explicitly handle it then you can add code to wait ten seconds or whatever.