Retry connecting to github because sometimes the connection is refused.
I added this code because when I tried to migrate issues the script stopped running after github refused a connection. Only a third of the issues were migrated and it wasn't going to be easy to migrate only the remaining issues. This change makes the script retry when github refuses the connection.
I'm hesitant to add this feature. There is no delay between requests, so if I'm thinking correctly, the script will continue to send out request after request as many times as it can each second.
I'd rather try to figure out why the request failed. And if there is no way to fix that failed request, perhaps the progress of the script can be stored in a "temporary file" and resumed once GitHub starts accepting requests again.
As for the why, how many issues were you importing at once? The GitHub API has a maximum number of requests per day *, so if the script exceeded that amount, that may have been why GitHub refused further requests for a while.
* Each individual issue requires several requests to complete: at least two requests for the issue itself, two for each and every comment on the issue, plus a few extra requests if you are retrieving a list of issues. It adds up quite fast!