title: Sending multiple POST requests to the same session using threading
body: <p>I am currently making a script which will add to cart and checkout items on e-commerce websites run on the shopify platform </p>
  
  <p>I'm trying to speed up the process by running the add to cart method on multiple threads. My add to cart function looks like this:</p>
  
  <pre><code>def add_to_cart(keywords,size,session,quantity=1):
       ...
  </code></pre>
  
  <p>where keywords is the list of strings so we can parse and find the correct item, and session is the a new session from the requests module. The function first parses through the sitemap, finding the unique product ID, then sends a post request to the session variable to add said item to cart.</p>
  
  <p>However, when I run the script using threads to add multiple items to cart, i only see one of the items in the cart. Why isn't this working? Would I need to lock + unlock the session variable and send the POST request one by one? </p>
  
  <p>Here's the code that I am running:</p>
  
  <pre><code>from ATC import *
  from checkout import *
  import requests
  import time
  import threading
  from bs4 import BeautifulSoup
  
  session = requests.Session()
  init = time.time()
  
  t1 = threading.Thread(target=add_to_cart, args=(['carabiner', 'black'], 'one size', session, 1,))
  t2 = threading.Thread(target=add_to_cart, args=(['drury', '8.2'], '8.2', session, 1,))
  t1.start()
  t2.start()
  t1.join()
  t2.join()
  now = time.time()
  print("Time Taken: " + str(format(now-init, '.3g')) + 's')
  </code></pre>