[openstack-dev] [infra][neutron]SystemExit() vs sys.exit()?

Doug Hellmann doug.hellmann at dreamhost.com
Fri May 2 14:28:48 UTC 2014


As Robert said, libraries should not be calling sys.exit() or raising
SystemExit directly, ever.

Throwing SystemExit from a library bypasses other exception handling
cleanup code higher in the stack that is unlikely to be looking for
fatal exceptions like SystemExit (because well-behaved libraries don't
throw those exceptions). Libraries should define meaningful
exceptions, subclassed from Exception, which the main application can
log before deciding whether to exit, retry, pick another driver, or
whatever.

On Fri, May 2, 2014 at 6:24 AM, Paul Michali (pcm) <pcm at cisco.com> wrote:
> On May 1, 2014, at 1:23 PM, Yuriy Taraday <yorik.sar at gmail.com> wrote:
>
>>
>> Coming back to topic, I'd prefer using standard library call because it can be mocked for testing.
>
> Yeah that’s probably the open question I still have. Does the community prefer raising a SystemError exception or use the sys.exit() call?
> Should we be consistent in our use?
>
> openstack at devstack-32:/opt/stack/neutron$ git grep sys.exit | wc -l
> 56
> openstack at devstack-32:/opt/stack/neutron$ git grep SystemExit | wc -l
> 57
>
>
> Regards,
>
> PCM (Paul Michali)
>
> MAIL …..…. pcm at cisco.com
> IRC ……..… pcm_ (irc.freenode.com)
> TW ………... @pmichali
> GPG Key … 4525ECC253E31A83
> Fingerprint .. 307A 96BB 1A4C D2C7 931D 8D2D 4525 ECC2 53E3 1A83
>
>
>>
>> --
>>
>> Kind regards, Yuriy.
>> _______________________________________________
>> OpenStack-dev mailing list
>> OpenStack-dev at lists.openstack.org
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
> _______________________________________________
> OpenStack-dev mailing list
> OpenStack-dev at lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev



More information about the OpenStack-dev mailing list