title: Celery task schedule (Ensuring a task is only executed one at a time)
body: <p>I have a task, somewhat like this:</p>
  <pre><code>@task()
  def async_work(info):
      ...
  </code></pre>
  <p>At any moment, I may call async_work with some info. For some reason, I need to make sure that only one async_work is running at a time, other calling request must wait for.</p>
  <p>So I come up with the following code:</p>
  <pre><code>is_locked = False    
  @task()
  def async_work(info):
      while is_locked:
          pass
      is_locked = True
      ...
      is_locked = False
  </code></pre>
  <p>But it says it's invalid to access local variables...
  How to solve it?</p>