mirror of https://gitlab.com/bashrc2/epicyon
get and post intervals set to one second
parent
d056f14ed6
commit
d532882972
|
@ -631,7 +631,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# should be above this
|
# should be above this
|
||||||
if self.server.GETbusy:
|
if self.server.GETbusy:
|
||||||
currTimeGET=int(time.time())
|
currTimeGET=int(time.time())
|
||||||
if currTimeGET-self.server.lastGET<10:
|
if currTimeGET-self.server.lastGET==0:
|
||||||
if self.server.debug:
|
if self.server.debug:
|
||||||
print('DEBUG: GET Busy')
|
print('DEBUG: GET Busy')
|
||||||
self.send_response(429)
|
self.send_response(429)
|
||||||
|
@ -1824,7 +1824,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
str(self.server.POSTbusy))
|
str(self.server.POSTbusy))
|
||||||
if self.server.POSTbusy:
|
if self.server.POSTbusy:
|
||||||
currTimePOST=int(time.time())
|
currTimePOST=int(time.time())
|
||||||
if currTimePOST-self.server.lastPOST<10:
|
if currTimePOST-self.server.lastPOST==0:
|
||||||
self.send_response(429)
|
self.send_response(429)
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
return
|
return
|
||||||
|
|
|
@ -42,11 +42,12 @@ def getJson(session,url: str,headers: {},params: {}, \
|
||||||
try:
|
try:
|
||||||
result=session.get(url, headers=sessionHeaders, params=sessionParams)
|
result=session.get(url, headers=sessionHeaders, params=sessionParams)
|
||||||
return result.json()
|
return result.json()
|
||||||
except:
|
except Exception as e:
|
||||||
print('ERROR: getJson failed')
|
print('ERROR: getJson failed')
|
||||||
print('url: '+url)
|
print('url: '+url)
|
||||||
print('headers: '+str(sessionHeaders))
|
print('headers: '+str(sessionHeaders))
|
||||||
print('params: '+str(sessionParams))
|
print('params: '+str(sessionParams))
|
||||||
|
print(e)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def postJson(session,postJsonObject: {},federationList: [],inboxUrl: str,headers: {},capability: str) -> str:
|
def postJson(session,postJsonObject: {},federationList: [],inboxUrl: str,headers: {},capability: str) -> str:
|
||||||
|
|
|
@ -57,10 +57,11 @@ def webfingerHandle(session,handle: str,httpPrefix: str,cachedWebfingers: {}, \
|
||||||
hdr = {'Accept': 'application/jrd+json'}
|
hdr = {'Accept': 'application/jrd+json'}
|
||||||
try:
|
try:
|
||||||
result = getJson(session, url, hdr, par,projectVersion,httpPrefix,fromDomain)
|
result = getJson(session, url, hdr, par,projectVersion,httpPrefix,fromDomain)
|
||||||
except:
|
except Exception as e:
|
||||||
print("Unable to webfinger " + url)
|
print("Unable to webfinger " + url)
|
||||||
print('headers: '+str(hdr))
|
print('headers: '+str(hdr))
|
||||||
print('params: '+str(par))
|
print('params: '+str(par))
|
||||||
|
print(e)
|
||||||
return None
|
return None
|
||||||
storeWebfingerInCache(nickname+'@'+wfDomain,result,cachedWebfingers)
|
storeWebfingerInCache(nickname+'@'+wfDomain,result,cachedWebfingers)
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Reference in New Issue