Changeset 105
- Timestamp:
- 08/16/06 09:36:51
- Files:
-
- recur.py (modified) (2 diffs)
- test_recur.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
recur.py
r104 r105 792 792 If the recurrence series is exhausted, self.nextrun will be None. 793 793 """ 794 if not self.recurrence: 795 self.nextrun = None 796 return 797 794 798 try: 795 799 next = self.recurrence.next() … … 896 900 def stop(self): 897 901 self.terminated = True 898 self.curthread.cancel() 902 if self.curthread: 903 self.curthread.cancel() 899 904 for w in self.workers.values(): 900 905 w.stop() test_recur.py
r103 r105 446 446 recur.Worker.__init__(self, *args, **params) 447 447 self.active = False 448 448 449 449 def work(self): 450 450 # This worker starts paused (inactive) and shouldn't do 451 451 # any work 452 452 paused[0] += 1 453 454 # the aptly named... 455 class WorkerNotAppearingInThisFilm(recur.Worker): 456 def work(self): 457 pass 453 458 454 459 s = recur.Scheduler({'mycounter': Counter("1 second")}) … … 461 466 s = recur.Scheduler({'c1': Counter("1 second"), 462 467 'c2': AnotherCounter("2 seconds"), 463 'c3': PausedWorker("1 second")}) 468 # A worker that starts paused (inactive). 469 'c3': PausedWorker("1 second"), 470 # A worker with an empty recurrence string. 471 # This is allowed in __init__, and sets 472 # self.recurrence to None. 473 'c4': WorkerNotAppearingInThisFilm("")}) 464 474 s.start() 465 475 try: … … 503 513 finally: 504 514 s.stop() 505 515 516 # Test a Scheduler with a single Worker with an empty recurrence string 517 s = recur.Scheduler({'w': WorkerNotAppearingInThisFilm("")}) 518 s.start() 519 time.sleep(0.5) 520 s.stop() 506 521 507 522 if __name__ == "__main__":
