From 63b7aa6d94632c6b68f48124df0f11486931c687 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 10 Mar 2021 19:11:14 +0000 Subject: [PATCH] Timeout when sending post via c2s --- posts.py | 2 +- session.py | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/posts.py b/posts.py index fcfe3bce4..e31a4e888 100644 --- a/posts.py +++ b/posts.py @@ -2141,7 +2141,7 @@ def sendPostViaServer(projectVersion: str, postDumps = json.dumps(postJsonObject) postResult = \ postJsonString(session, postDumps, [], - inboxUrl, headers, debug) + inboxUrl, headers, debug, 60) if not postResult: if debug: print('DEBUG: POST failed for c2s to '+inboxUrl) diff --git a/session.py b/session.py index 2661c6ffc..14e5b8666 100644 --- a/session.py +++ b/session.py @@ -173,7 +173,8 @@ def postJsonString(session, postJsonStr: str, federationList: [], inboxUrl: str, headers: {}, - debug: bool) -> (bool, bool): + debug: bool, + timeoutSec=30) -> (bool, bool): """Post a json message string to the inbox of another person The second boolean returned is true if the send is unauthorized NOTE: Here we post a string rather than the original json so that @@ -182,7 +183,8 @@ def postJsonString(session, postJsonStr: str, """ try: postResult = \ - session.post(url=inboxUrl, data=postJsonStr, headers=headers) + session.post(url=inboxUrl, data=postJsonStr, + headers=headers, timeout=timeoutSec) except requests.exceptions.RequestException as e: print('WARN: error during postJsonString requests') print(e)