public inbox for cygwin-apps-cvs@sourceware.org
help / color / mirror / Atom feed
* [calm - Cygwin server-side packaging maintenance script] branch master, updated. 20160705-65-geca884d
@ 2017-04-12 11:32 jturney
  0 siblings, 0 replies; only message in thread
From: jturney @ 2017-04-12 11:32 UTC (permalink / raw)
  To: cygwin-apps-cvs




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/calm.git;h=eca884d381ce3d1ab5e430850ad54b64aec48f14

commit eca884d381ce3d1ab5e430850ad54b64aec48f14
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Wed Apr 12 12:21:44 2017 +0100

    Log exceptions in daemon mode


Diff:
---
 calm/calm.py |   75 ++++++++++++++++++++++++++++++---------------------------
 1 files changed, 39 insertions(+), 36 deletions(-)

diff --git a/calm/calm.py b/calm/calm.py
index c01bc1a..0a66074 100755
--- a/calm/calm.py
+++ b/calm/calm.py
@@ -489,42 +489,45 @@ def do_daemon(args, state):
 
         state.packages = {}
 
-        while running:
-            with mail_logs(args.email, toaddrs=args.email, subject='%s' % (state.subject), thresholdLevel=logging.ERROR) as leads_email:
-                # re-read relarea on SIGALRM or SIGUSR2
-                if read_relarea:
-                    read_relarea = False
-                    state.packages = process_relarea(args)
-
-                if not state.packages:
-                    logging.error("not processing uploads or writing setup.ini")
-                else:
-                    if read_uploads:
-                        # read uploads on SIGUSR1
-                        read_uploads = False
-                        state.packages = process_uploads(args, state)
-
-                    do_output(args, state)
-
-                    # if there is more work to do, but don't spin if we can't do it
-                    if read_uploads:
-                        continue
-
-            # we wake at a 10 minute offset from the next 30 minute boundary
-            # (i.e. at :10 or :40 past the hour) to check the state of the
-            # release area, in case someone has ninja-ed in a change there...
-            interval = 30*60
-            offset = 10*60
-            delay = interval - ((time.time() - offset) % interval)
-            signal.alarm(int(delay))
-
-            # wait until interrupted by a signal
-            logging.info("sleeping for %d seconds" % (delay))
-            signal.pause()
-            logging.info("woken")
-
-            # cancel any pending alarm
-            signal.alarm(0)
+        try:
+            while running:
+                with mail_logs(args.email, toaddrs=args.email, subject='%s' % (state.subject), thresholdLevel=logging.ERROR) as leads_email:
+                    # re-read relarea on SIGALRM or SIGUSR2
+                    if read_relarea:
+                        read_relarea = False
+                        state.packages = process_relarea(args)
+
+                    if not state.packages:
+                        logging.error("not processing uploads or writing setup.ini")
+                    else:
+                        if read_uploads:
+                            # read uploads on SIGUSR1
+                            read_uploads = False
+                            state.packages = process_uploads(args, state)
+
+                        do_output(args, state)
+
+                        # if there is more work to do, but don't spin if we can't do it
+                        if read_uploads:
+                            continue
+
+                # we wake at a 10 minute offset from the next 30 minute boundary
+                # (i.e. at :10 or :40 past the hour) to check the state of the
+                # release area, in case someone has ninja-ed in a change there...
+                interval = 30*60
+                offset = 10*60
+                delay = interval - ((time.time() - offset) % interval)
+                signal.alarm(int(delay))
+
+                # wait until interrupted by a signal
+                logging.info("sleeping for %d seconds" % (delay))
+                signal.pause()
+                logging.info("woken")
+
+                # cancel any pending alarm
+                signal.alarm(0)
+        except Exception as e:
+            logging.error("exception %s" % (type(e).__name__), exc_info=True)
 
         logging.info("calm daemon stopped")
 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-04-12 11:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-12 11:32 [calm - Cygwin server-side packaging maintenance script] branch master, updated. 20160705-65-geca884d jturney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).