Timeout when sending post via c2s

merge-requests/30/head
Bob Mottram 2021-03-10 19:11:14 +00:00
parent 0b7cf977fb
commit 63b7aa6d94
2 changed files with 5 additions and 3 deletions

View File

@ -2141,7 +2141,7 @@ def sendPostViaServer(projectVersion: str,
postDumps = json.dumps(postJsonObject) postDumps = json.dumps(postJsonObject)
postResult = \ postResult = \
postJsonString(session, postDumps, [], postJsonString(session, postDumps, [],
inboxUrl, headers, debug) inboxUrl, headers, debug, 60)
if not postResult: if not postResult:
if debug: if debug:
print('DEBUG: POST failed for c2s to '+inboxUrl) print('DEBUG: POST failed for c2s to '+inboxUrl)

View File

@ -173,7 +173,8 @@ def postJsonString(session, postJsonStr: str,
federationList: [], federationList: [],
inboxUrl: str, inboxUrl: str,
headers: {}, headers: {},
debug: bool) -> (bool, bool): debug: bool,
timeoutSec=30) -> (bool, bool):
"""Post a json message string to the inbox of another person """Post a json message string to the inbox of another person
The second boolean returned is true if the send is unauthorized The second boolean returned is true if the send is unauthorized
NOTE: Here we post a string rather than the original json so that NOTE: Here we post a string rather than the original json so that
@ -182,7 +183,8 @@ def postJsonString(session, postJsonStr: str,
""" """
try: try:
postResult = \ 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: except requests.exceptions.RequestException as e:
print('WARN: error during postJsonString requests') print('WARN: error during postJsonString requests')
print(e) print(e)