[openstack-dev] [infra][neutron]SystemExit() vs sys.exit()?
Yuriy Taraday
yorik.sar at gmail.com
Thu May 1 17:23:02 UTC 2014
On Thu, May 1, 2014 at 8:17 PM, Salvatore Orlando <sorlando at nicira.com>wrote:
> The patch you've been looking at just changes the way in which SystemExit
> is used, it does not replace it with sys.exit.
> In my experience sys.exit was causing unit test threads to interrupt
> abruptly, whereas SystemExit was being caught by the test runner and
> handled.
>
According to https://docs.python.org/2.7/library/sys.html#sys.exit ,
sys.exit(n) is an equivalent for raise SystemExit(n), it can be confirmed
in the source code here:
http://hg.python.org/cpython/file/2.7/Python/sysmodule.c#l206
If there's any difference in behavior it seems to be the problem of test
runner. For example, it can mock sys.exit somehow.
I find therefore a bit strange that you're reporting what appears to be
> the opposite behaviour.
>
> Maybe if you could share the code you're working on we can have a look at
> it and see what's going on.
>
I'd suggest finding out what's the difference in both of your cases.
Coming back to topic, I'd prefer using standard library call because it can
be mocked for testing.
--
Kind regards, Yuriy.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140501/4c27fc3e/attachment.html>
More information about the OpenStack-dev
mailing list