From 62ae21dd3e9a37fa1deb45985d1a2705db5233a9 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 10 Mar 2021 18:41:13 +0000 Subject: [PATCH] json post timeout --- like.py | 2 +- notifications_client.py | 2 +- session.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/like.py b/like.py index 8378032fb..8975207f0 100644 --- a/like.py +++ b/like.py @@ -203,7 +203,7 @@ def sendLikeViaServer(baseDir: str, session, 'Content-type': 'application/json', 'Authorization': authHeader } - postResult = postJson(session, newLikeJson, [], inboxUrl, headers) + postResult = postJson(session, newLikeJson, [], inboxUrl, headers, 30) if not postResult: print('WARN: POST announce failed for c2s to ' + inboxUrl) return 5 diff --git a/notifications_client.py b/notifications_client.py index e224ac9a3..533825585 100644 --- a/notifications_client.py +++ b/notifications_client.py @@ -348,7 +348,7 @@ def runNotificationsClient(baseDir: str, proxyType: str, httpPrefix: str, _sayCommand(sayStr, screenreader, systemLanguage, espeak) if screenreader: - keyPress = _waitForKeypress(2, debug) + keyPress = _waitForKeypress(2, dbug) break elif keyPress == 'reply' or keyPress == 'r': if speakerJson.get('id'): diff --git a/session.py b/session.py index b3008fb1c..2661c6ffc 100644 --- a/session.py +++ b/session.py @@ -137,7 +137,7 @@ def getJson(session, url: str, headers: {}, params: {}, def postJson(session, postJsonObject: {}, federationList: [], - inboxUrl: str, headers: {}) -> str: + inboxUrl: str, headers: {}, timeoutSec=60) -> str: """Post a json message to the inbox of another person """ # check that we are posting to a permitted domain @@ -149,7 +149,7 @@ def postJson(session, postJsonObject: {}, federationList: [], postResult = \ session.post(url=inboxUrl, data=json.dumps(postJsonObject), - headers=headers) + headers=headers, timeout=timeoutSec) except requests.exceptions.RequestException as e: print('ERROR: postJson requests failed ' + inboxUrl + ' ' + json.dumps(postJsonObject) + ' ' + str(headers))