title: Maximum number of running instances reached (1) - apscheduler
body: <p>I'm using apscheduler to recursively run a function in my application. The basic source of this functionality is as follows:</p>
  
  <pre><code>class ClassName(QtGui.QWidget)
      def __init__(self):
          super(ClassName, self).__init__()
  
          from apscheduler.scheduler import Scheduler
          sched = Scheduler(standalone=True)
          sched.daemonic = False
          sched.add_cron_job(self.FunctionName, second='*/5')
  
      def FunctionName(self):
          print("Hello World!")
          #Function contents here
  
      if __name__ == '__main__':
          import sys
          app = QtGui.QApplication(sys.argv)
          ClassName = ClassName()
          sys.exit(app.exec_())
  </code></pre>
  
  <p>My understanding from reading <a href="https://stackoverflow.com/questions/20264298/warningapscheduler-schedulerexecution-of-job-skipped-maximum-number-of-runnin">this</a> thread, is that if the called function hasn't completed when the next job is started, the "Maximum number of running instances reached" error can be raised. I understand the theory behind the solution in that thread, but am unsure on the application.</p>
  
  <p>Should I explicitly state, at the end of the called function, the terminate/kill a process to ensure that the original thread is removed before the next thread is started?</p>