The selector prints proxy A, then proxy B. The request log keeps showing proxy A. A network service is not needed to explain that contradiction: the caller may have discarded the selector's return value.

Trace the value into the call that sends the request:

endpoint = choose_proxy()
routes = {'http': endpoint, 'https': endpoint}
response = session.get(target_url, proxies=routes, timeout=15)

This fragment assumes an existing Requests session and a validated proxy URL. For public requests allowed through public intermediaries, the free proxy list provides candidate URLs to pass through the same selection-and-send path. The supported keyword is proxies. A helper that prints a mapping, or returns one that nobody assigns, cannot replace the mapping supplied here.

Keep the selected route local to the operation. In concurrent code, a shared current_proxy field can change between logging and sending. Another worker's selection can then appear beside the wrong outcome.

Use an attempt identifier to connect the selection, send configuration, and result. Log a safe endpoint identifier rather than the complete URL when it contains credentials.

If those values agree but the observed public IP does not change, you have reached a different question: whether the selected endpoints provide distinct exits or a rotating gateway retains a connection. First settle whether the application sent the route it claimed to select. Otherwise provider-side speculation can hide a simple stale variable for hours.

متعلقہ مضامین