From b61ec6f73e5566525a9b32e466843fd11817556d Mon Sep 17 00:00:00 2001 From: lolamathematician <45736281+lolamathematician@users.noreply.github.com> Date: Fri, 24 Jul 2020 11:19:01 +0100 Subject: [PATCH] Resolving TypeError I hit an error > psaw ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host On inspecting the stack trace there were a couple of exceptions the final of which was not handled and terminated the program. Final error > log.debug("Connection error caught, retrying. Connection attempts so far: %s" % i+1) > TypeError: can only concatenate str (not "int") to str I did not capture the full stack trace at the time and am currently unable to replicate but it was resolved with the proposed change. --- psaw/PushshiftAPI.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/psaw/PushshiftAPI.py b/psaw/PushshiftAPI.py index b2f3467..c12d3d6 100644 --- a/psaw/PushshiftAPI.py +++ b/psaw/PushshiftAPI.py @@ -185,7 +185,7 @@ def _get(self, url, payload={}): log.info(response.url) log.debug('Response status code: %s' % response.status_code) except requests.ConnectionError: - log.debug("Connection error caught, retrying. Connection attempts so far: %s" % i+1) + log.debug("Connection error caught, retrying. Connection attempts so far: %s" % str(i+1)) continue success = response.status_code == 200 if not success: