Set some timeouts for initial connection to instance

This commit is contained in:
localhost_frssoft 2023-06-25 15:05:40 +03:00
parent 50e8a30852
commit da86e366a9

View File

@ -48,7 +48,7 @@ class current_instance:
current_instance.token = new_token current_instance.token = new_token
current_instance.listen_token = None current_instance.listen_token = None
if new_token: if new_token:
current_instance.s.get(f'https://{current_instance.instance}') current_instance.s.get(f'https://{current_instance.instance}', timeout=30)
current_instance.s.headers.update({"Authorization": "Bearer " + new_token}) current_instance.s.headers.update({"Authorization": "Bearer " + new_token})
@ -56,7 +56,7 @@ if current_instance.token:
current_instance.s.headers.update({"Authorization": "Bearer " + current_instance.token}) current_instance.s.headers.update({"Authorization": "Bearer " + current_instance.token})
else: else:
# Get cookies from unauthorized instance for working some functionality (radios) # Get cookies from unauthorized instance for working some functionality (radios)
current_instance.s.get(f'https://{current_instance.instance}/') current_instance.s.get(f'https://{current_instance.instance}/', timeout=30)
@logger.catch @logger.catch
@ -79,7 +79,8 @@ def get_instance_settings():
def get_node_info(): def get_node_info():
r = current_instance.s.get( r = current_instance.s.get(
f'https://{current_instance.instance}/api/v1/instance/nodeinfo/2.0/') f'https://{current_instance.instance}/api/v1/instance/nodeinfo/2.0/',
timeout=30)
r.raise_for_status() r.raise_for_status()
return r.json() return r.json()