Reputation: 41
I was wondering if it is possible to run threads each with its own environment variables.
I am currently using environment variables to set my proxies like this:
os.environ["HTTP_PROXY"] = proxy["http"]
os.environ["HTTPS_PROXY"] = proxy["https"]
But I noticed that each thread will just use the proxy that has last been set. It is not possible for me to use the requests library for this purpose.
Is there a way that I can achieve this without using requests.Session()
for each thread?
Upvotes: 0
Views: 1601
Reputation: 7469
I was wondering if it is possible to run threads each with its own environment variables.
No. Env vars live in the address space of the process and thus are global to all threads of the process.
Upvotes: 2