title: AppConfig.ready() is Running Twice on Django Setup (Using Heroku)
body: <p>I have a function that needs to run in the background on one of my web applications.</p>
  
  <p>I implemented a custom AppConfig as shown below:</p>
  
  <pre><code>class MyAppConfig(AppConfig):
      run_already = False
  
      def ready(self):
          from .tasks import update_products
          if "manage.py" not in sys.argv and not self.run_already:
              self.run_already = True
              update_products()
  </code></pre>
  
  <p>However, this command is being executed twice (the update_products() call)</p>
  
  <p><a href="https://docs.djangoproject.com/en/1.11/ref/applications/" rel="noreferrer">As stated in the documentation:</a></p>
  
  <blockquote>
    <p>In the usual initialization process, the ready method is only called
    once by Django. But in some corner cases, particularly in tests which
    are fiddling with installed applications, ready might be called more
    than once. In that case, either write idempotent methods, or put a
    flag on your AppConfig classes to prevent re-running code which should
    be executed exactly one time.</p>
  </blockquote>
  
  <p>I feel like I am following what the documentation says to do.  What gives?</p>