I_SERIALIZABLE = 2
__all__ = ['DBScript', 'I_AUTOCOMMIT', 'I_READ_COMMITTED', 'I_SERIALIZABLE',
- 'signal_pidfile']
+ 'signal_pidfile', 'UsageError']
#__all__ += ['daemonize', 'run_single_process']
+class UsageError(Exception):
+ """User induced error."""
+ pass
+
#
# utils
#
try:
run_single_process(self, self.go_daemon, self.pidfile)
+ except UsageError, ex:
+ self.log.error(str(ex))
+ sys.exit(1)
except KeyboardInterrupt:
raise
except SystemExit:
# run startup, safely
try:
self.startup()
+ except UsageError, ex:
+ self.log.error(str(ex))
+ sys.exit(1)
except KeyboardInterrupt:
raise
except SystemExit:
"Run users work function, safely."
try:
return self.work()
+ except UsageError, ex:
+ self.log.error(str(ex))
+ # should we exit here?
except SystemExit, d:
self.send_stats()
self.log.info("got SystemExit(%s), exiting" % str(d))
del tb
self.log.exception("Job %s crashed: %s: %s" % (
self.job_name, str(exc), str(msg).rstrip()))
- self.reset()
- if self.looping and not self.do_single_loop:
- time.sleep(20)
- return 1
- else:
- sys.exit(1)
+
+ # reset and sleep
+ self.reset()
+ if self.looping and not self.do_single_loop:
+ time.sleep(20)
+ return 1
+ else:
+ sys.exit(1)
def work(self):
"""Here should user's processing happen.