title: How to pass and run a callback method in Python
body: <p>I have a Manager (main thread), that creates other Threads to handle various operations.
  I would like my Manager to be notified when a Thread it created ends (when run() method execution is finished).</p>
  
  <p>I know I could do it by checking the status of all my threads with the Thread.isActive() method, but polling sucks, so I wanted to have notifications.</p>
  
  <p>I was thinking of giving a callback method to the Threads, and call this function at the end of the run() method:</p>
  
  <pre><code>class Manager():
      ...
      MyThread(self.on_thread_finished).start() # How do I pass the callback
  
      def on_thread_finished(self, data):
          pass
      ...
  
  class MyThread(Thread):
      ...
      def run(self):
          ....
          self.callback(data) # How do I call the callback?
      ...
  </code></pre>
  
  <p>Thanks!</p>