More clear variable names and docs on Make HTTPx Client. But it always returned boolean

This commit is contained in:
SimplifiedPrivacy 2026-08-13 06:11:14 -04:00
parent 951802fe5c
commit b5e72ae7f6

View file

@ -44,7 +44,7 @@ def single_endpoint(method: str, url: str, observer: ConnectionObserver, payload
########################################################
if client is None:
observer.notify('message', "Testing Connection..")
made_client = make_client(connection_type, observer)
made_client = make_client(connection_type, observer) # makes boolean
if not made_client and connection_type == ConnectionChoice.TOR:
observer.notify('message', "Tor Bootstrap..")
return bootstrap_and_try_again(
@ -114,13 +114,16 @@ def single_endpoint(method: str, url: str, observer: ConnectionObserver, payload
return initial_result
def make_client(connection_type: str, observer: Optional[ConnectionObserver] = None) -> httpx.Client | ApiResponse:
def make_client(connection_type: str, observer: Optional[ConnectionObserver] = None) -> bool:
"""
Rank:
Coordinator
Purpose:
Create an HTTPx Client for either kind of transport
Returns:
Boolean of result
"""
global _port_used
@ -128,20 +131,21 @@ def make_client(connection_type: str, observer: Optional[ConnectionObserver] = N
if connection_type == ConnectionChoice.SYSTEM:
return httpx_client.init_session() # this is not the client, its a boolean
# Tor:
if _port_used is None:
_port_used = Constants.DEFAULT_TOR_PORT
logger.info(f"Set to default port of {Constants.DEFAULT_TOR_PORT}")
# Tor:
# check if port is even listening:
listening = ports.is_port_in_use(_port_used)
if listening:
client = httpx_client.init_tor_session(_port_used)
if client:
return client
boolean_if_worked = httpx_client.init_tor_session(_port_used)
if boolean_if_worked:
return True
else:
logger.error(f"Could NOT create a Tor HTTPx client on port {_port_used}.. Bootstrapping..")
return False
return False