Warning:
Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.
Ticket #2472: use-logging-api-instead-of-print.patch
| File use-logging-api-instead-of-print.patch,
2.0 KB
(added by bochecha, 2 years ago) |
|
|
-
|
|
|
|
| 354 | 354 | try: |
| 355 | 355 | self.sched.run() |
| 356 | 356 | except Exception, err: |
| 357 | | print >> sys.stderr, "ERROR DURING SCHEDULER EXECUTION", err |
| 358 | | print >> sys.stderr, "".join( |
| 359 | | traceback.format_exception(*sys.exc_info())) |
| 360 | | print >> sys.stderr, "-" * 20 |
| | 357 | logger.error("ERROR DURING SCHEDULER EXECUTION", err) |
| | 358 | logger.error("".join( |
| | 359 | traceback.format_exception(*sys.exc_info()))) |
| | 360 | logger.error("-" * 20) |
| 361 | 361 | # queue is empty; sleep a short while before checking again |
| 362 | 362 | if self.running: |
| 363 | 363 | time.sleep(5) |
| … |
… |
|
| 392 | 392 | |
| 393 | 393 | def handle_exception(self, exc): |
| 394 | 394 | """ Handle any exception that occured during task execution. """ |
| 395 | | print >> sys.stderr, "ERROR DURING TASK EXECUTION", exc |
| 396 | | print >> sys.stderr, "".join(traceback.format_exception(*sys.exc_info())) |
| 397 | | print >> sys.stderr, "-" * 20 |
| | 395 | logger.error("ERROR DURING TASK EXECUTION", exc) |
| | 396 | logger.error("".join(traceback.format_exception(*sys.exc_info()))) |
| | 397 | logger.error("-" * 20) |
| 398 | 398 | |
| 399 | 399 | |
| 400 | 400 | class SingleTask(Task): |
| … |
… |
|
| 645 | 645 | |
| 646 | 646 | if __name__ == "__main__": |
| 647 | 647 | def testaction(arg): |
| 648 | | print ">>>TASK", arg, "sleeping 3 seconds" |
| | 648 | logger.info(">>>TASK", arg, "sleeping 3 seconds") |
| 649 | 649 | time.sleep(3) |
| 650 | | print "<<<END_TASK", arg |
| | 650 | logger.info("<<<END_TASK", arg) |
| 651 | 651 | |
| 652 | 652 | s = ThreadedScheduler() |
| 653 | 653 | s.add_interval_task( testaction, "test action 1", 0, 4, method.threaded, ["task 1"], None ) |
| 654 | 654 | s.start() |
| 655 | 655 | |
| 656 | | print "Scheduler started, waiting 15 sec...." |
| | 656 | logger.info("Scheduler started, waiting 15 sec....") |
| 657 | 657 | time.sleep(15) |
| 658 | 658 | |
| 659 | | print "STOP SCHEDULER" |
| | 659 | logger.info("STOP SCHEDULER") |
| 660 | 660 | s.stop() |
| 661 | 661 | |
| 662 | | print "EXITING" |
| | 662 | logger.info("EXITING") |
Download in other formats: