[PATCH 11 of 11] merge: don't fiddle with name lookups or i18n in hot loops

Idan Kamara idankk86 at gmail.com
Tue Feb 12 03:26:23 CST 2013


On Tue, Feb 12, 2013 at 3:02 AM, Bryan O'Sullivan <bos at serpentine.com>
wrote:
>
> On Sun, Feb 10, 2013 at 3:25 AM, Idan Kamara <idankk86 at gmail.com> wrote:
>>
>> No, he didn't. And had he given me the chance to reply to his last
>> response, I would have shown it:
>
>
> Yep, that's a bug. But it's just a bug - I fixed another one in the new
> parallel code just a little while ago.

So we should exit on all exceptions, but we can't print a traceback
since that's not desirable when not running from the command line
(and it wasn't readable anyway since they got interleaved in one
another).

Maybe we should serialize the exceptions to the master and have
him decide what to do (e.g. reraise)?

>
>>
>> And the only reason the sys.exit I had a problem with is
>> 'working' is thanks to this:
>>
>> http://selenic.com/repo/hg/file/0027a5cec9d0/mercurial/dispatch.py#l201
>
>
> Correct, and that's deliberate. Perhaps you could tell me what you'd
> rather see, because I obviously think the use of sys.exit in this context
is
> reasonable based on what I currently know.

I think raising util.Abort instead should do it.

I wrote this test to check these things:

import unittest, silenttestrunner, os

from mercurial import worker, ui, util

class testworker(unittest.TestCase):
    def testchilderror(self):
        def workerfunc(x):
            raise util.Abort

        g = worker._platformworker(ui.ui(), workerfunc, (), [1])
        self.assertRaises(util.Abort, g.next)

if __name__ == '__main__':
    silenttestrunner.main(__name__)

It will currently fail on a StopIteration because the child doesn't exit,
making it call g.next on a finished generator. So doing this fixes it:

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -83,7 +83,7 @@
                 for i, item in func(*(staticargs + (pargs,))):
                     os.write(wfd, '%d %s\n' % (i, item))
                 os._exit(0)
-            except KeyboardInterrupt:
+            except:
                 os._exit(255)
     os.close(wfd)
     fp = os.fdopen(rfd, 'rb', 0)
@@ -96,7 +96,7 @@
         for i in xrange(workers):
             problems |= os.wait()[1]
         if problems:
-            sys.exit(1)
+            raise util.Abort(_('child error'))
     try:
         for line in fp:
             l = line.split(' ', 1)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20130212/4c9093b9/attachment.html>


More information about the Mercurial-devel mailing list