title: Callback on variable change in python
body: <p>I've searched around but didn't find anything like this. Let's say I have an army of threads, that keep reading and updating an integer variable <code>x</code>. I would like a callback for when <code>x</code> changes over a certain margin, let's say 500, to run the callback. </p>
  
  <p>How can this be done without putting a heavy load on the system, like having a thread that has a <code>while true</code> and checks if the variable has changed?  Performance is critical. But so are ethics.</p>
  
  <p>In plain code would be something like this:</p>
  
  <pre><code>x = 10
  def runMe():
      print('Its greater than 500!!') 
  
  def whenToRun():
      return x &gt;= 500
  
  triggers.event(runMe, whenToRun)
  </code></pre>