title: How to multithread a function in Flask?
body: <p>I have a function that gets the current price of any currency that i choose using the <a href="https://finance.google.com/finance/converter?a=1&amp;from=USD&amp;to=KGS&amp;meta=ei%3DrD_0WeDcKsmLswHihJmoDQ" rel="nofollow noreferrer">financial google</a>, i want to multithread it so i can send any request separately .</p>
  
  <p>Here is my <strong>code</strong>:</p>
  
  <pre><code>def currency_converter(amount, currency):
      url = 'https://finance.google.com/finance/converter?a={}&amp;from=KGS&amp;to={}&amp;meta=ei%3DmSr0WeHCCYvBsAH8n6OIBA'.format(amount, currency)
      urlHandler = urllib2.urlopen(url)
      html = urlHandler.read()
      bsoup = BeautifulSoup(html, 'lxml')
      num = bsoup.find('span').text.split()[0]
      return float(num)
  
  @main_route.app_template_filter('currency_converter')
  def thread_me(amount, currency):
      t = threading.Thread(target=currency_converter, args=[amount, currency])
      t.start()
      t.join()
      return t
  </code></pre>
  
  <p>here is how i run the filter inside my template:</p>
  
  <p><code>{{ product.price|float|currency_converter('RUB') }} руб</code></p>
  
  <p>Here i am returning the t value , i want to return the data from the api , please how can i make that done ??</p>
  
  <p>Another problem that i forgot to mention that, if i opened any product page the page delays for about 10 seconds !!</p>