title: python: run functions in parallel
body: <p>I want to run two functions in parallel. These functions are executed many times in a loop.
  Here is my code:</p>
  
  <pre><code>#get the html content of the first rental
  previous_url_rental=BeautifulSoup(urllib.urlopen(rentals[0]))
  
  #for each rental on the page
  for rental_num in xrange(1, len(rentals)):
      #get the html content of the page
      url_rental=BeautifulSoup(urllib.urlopen(rentals[rental_num]))
      #get and save the rental data in the csv file
      writer.writerow(get_data_rental(previous_url_rental))
      previous_url_rental=url_rental
  
  #save last rental
  writer.writerow(get_data_rental(previous_url_rental))
  </code></pre>
  
  <p>There are two main things: </p>
  
  <p>1/ get the html content of a page: 
  <code>url_rental=BeautifulSoup(urllib.urlopen(rentals[rental_num]))</code> </p>
  
  <p>2/ retrieve and save data from the html content of the previous page (and not the current page because these 2 processes would be dependent): 
  <code>writer.writerow(get_data_rental(previous_url_rental))</code></p>
  
  <p>I would like to run these two lines in parallel: a first process would get the html content of the page <code>n+1</code> while a second process would retrieve and save the data of the page <code>n</code>.
  I have searched and found this post so far: <a href="https://stackoverflow.com/questions/7207309/python-how-can-i-run-python-functions-in-parallel">Python: How can I run python functions in parallel?</a>. But I don't understand how to use it!</p>
  
  <p>Thank you for your time.</p>