title: Improving Implementation of current celery process
body: <p>I have been working with celery recently. I haven't used it much before but I wanted to use to process sql queries to my database in an async way so that 1 data point doesn't prevent the webpage from loading. (Is that a good use case?)</p>
  
  <p>I have implemented something like below, but it seems redundant and there might be a better way of doing this. I would really appreciate some criticism and suggestions.</p>
  
  <p>Example Code:</p>
  
  <pre class="lang-py prettyprint-override"><code>@celery.task
  def _get_player_name(player_tag):
      player = PlayerStatsCurrent.query.filter_by(player_tag=player_tag).first()
      return player.player_name
  
  def get_player_name(player_tag):
      result = _get_player_name.delay(player_tag)
      while not result.ready():
          time.sleep(0.5)
      player_name = result.get()
      return player_name
  </code></pre>
  
  <p>In the above example, my webpage calls on <code>get_player_name</code> along with some other functions that look similar but are more computationally expensive.</p>
  
  <p>The code works. And I get the output as expected. I just want to make it more "pythonic" cause it doesn't seem DRY right now and I'm not great at celery to know how to do so. Thank you in advance for your help.</p>