Patchwork [2,of,2] worker: catch all exceptions, try to exit usefully/safely

login
register
mail settings
Submitter Bryan O'Sullivan
Date April 11, 2013, 8:30 p.m.
Message ID <dbcff0d4ff471fea5f2a.1365712249@dev1718.prn1.facebook.com>
Download mbox | patch
Permalink /patch/1273/
State Accepted, archived
Delegated to: Augie Fackler
Headers show

Comments

Bryan O'Sullivan - April 11, 2013, 8:30 p.m.
# HG changeset patch
# User Bryan O'Sullivan <bryano@fb.com>
# Date 1365712231 25200
#      Thu Apr 11 13:30:31 2013 -0700
# Node ID dbcff0d4ff471fea5f2aae5a38aae36e367641b1
# Parent  3d2ead77daf3f2ec8a49fa4baf0cfb69e20fbaa6
worker: catch all exceptions, try to exit usefully/safely
Augie Fackler - April 12, 2013, 8:40 p.m.
Both LG, queued


On Thu, Apr 11, 2013 at 01:30:49PM -0700, Bryan O'Sullivan wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bryano@fb.com>
> # Date 1365712231 25200
> #      Thu Apr 11 13:30:31 2013 -0700
> # Node ID dbcff0d4ff471fea5f2aae5a38aae36e367641b1
> # Parent  3d2ead77daf3f2ec8a49fa4baf0cfb69e20fbaa6
> worker: catch all exceptions, try to exit usefully/safely
>
> diff --git a/mercurial/worker.py b/mercurial/worker.py
> --- a/mercurial/worker.py
> +++ b/mercurial/worker.py
> @@ -89,6 +89,11 @@
>                  os._exit(0)
>              except KeyboardInterrupt:
>                  os._exit(255)
> +            except: # re-raises (close enough for debugging anyway)
> +                try:
> +                    ui.traceback()
> +                finally:
> +                    os._exit(255)
>          pids.append(pid)
>      pids.reverse()
>      os.close(wfd)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -89,6 +89,11 @@ 
                 os._exit(0)
             except KeyboardInterrupt:
                 os._exit(255)
+            except: # re-raises (close enough for debugging anyway)
+                try:
+                    ui.traceback()
+                finally:
+                    os._exit(255)
         pids.append(pid)
     pids.reverse()
     os.close(wfd)