From d5328829721bb915a9cb45a01645748864f3190b Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 14 Aug 2019 23:24:51 +0100 Subject: [PATCH] get and post intervals set to one second --- daemon.py | 4 ++-- session.py | 3 ++- webfinger.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/daemon.py b/daemon.py index 02a771865..f2235dd31 100644 --- a/daemon.py +++ b/daemon.py @@ -631,7 +631,7 @@ class PubServer(BaseHTTPRequestHandler): # should be above this if self.server.GETbusy: currTimeGET=int(time.time()) - if currTimeGET-self.server.lastGET<10: + if currTimeGET-self.server.lastGET==0: if self.server.debug: print('DEBUG: GET Busy') self.send_response(429) @@ -1824,7 +1824,7 @@ class PubServer(BaseHTTPRequestHandler): str(self.server.POSTbusy)) if self.server.POSTbusy: currTimePOST=int(time.time()) - if currTimePOST-self.server.lastPOST<10: + if currTimePOST-self.server.lastPOST==0: self.send_response(429) self.end_headers() return diff --git a/session.py b/session.py index 5ebc49a95..3e1f876a7 100644 --- a/session.py +++ b/session.py @@ -42,11 +42,12 @@ def getJson(session,url: str,headers: {},params: {}, \ try: result=session.get(url, headers=sessionHeaders, params=sessionParams) return result.json() - except: + except Exception as e: print('ERROR: getJson failed') print('url: '+url) print('headers: '+str(sessionHeaders)) print('params: '+str(sessionParams)) + print(e) return None def postJson(session,postJsonObject: {},federationList: [],inboxUrl: str,headers: {},capability: str) -> str: diff --git a/webfinger.py b/webfinger.py index b5becf4fc..73d077d2a 100644 --- a/webfinger.py +++ b/webfinger.py @@ -57,10 +57,11 @@ def webfingerHandle(session,handle: str,httpPrefix: str,cachedWebfingers: {}, \ hdr = {'Accept': 'application/jrd+json'} try: result = getJson(session, url, hdr, par,projectVersion,httpPrefix,fromDomain) - except: + except Exception as e: print("Unable to webfinger " + url) print('headers: '+str(hdr)) print('params: '+str(par)) + print(e) return None storeWebfingerInCache(nickname+'@'+wfDomain,result,cachedWebfingers) return result