0

I'm trying to understand whether requests.post is thread safe. In other words, assuming the server side can (and will) handle multiple requests concurrently, will something like this

def f(i) :
    response = requests.post(...)
    # do something with the response

with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
    for i in range(10):
        executor.submit(func, i)

work as expected?

this question and the discussion around it suggest that although the requests package claims to be thread-safe the Session() object is not thread safe. Anyway, it's not clear to me whether this has any bearing on my specific case or not (perhaps because I don't have a clear grasp of the relationship between sessions, cookies, and the requests.post operation).

Just Me
  • 393
  • 2
  • 9

0 Answers0