[Bf-committers] blender exit code after exec python

Diego Gangl dnicolas at gmail.com
Wed Dec 30 18:48:17 CET 2015


Hi,

I don't know if this is by design, but it makes sense if it were. Scripts
are run inside Blender, but they are not blender and the interpreter isn't
the main function (even on background).

For a cleaner way to exit, you can use a SystemExit exception like this:

raise SystemExit("oops")

It will print "oops" and set the exit code to 1. You can pass an integer
instead of a string to set the exit code manually too.

Cheers,

2015-12-30 13:15 GMT-03:00 François T. <francoistarlier at gmail.com>:

> Hello guys,
>
> I'm asking here because I'm not quite sure it is a bug or design matter.
>
> We are using blender on our renderfarm (Deadline) to generate some datas
> with a python script using the following command :
> blender --background --python script.py
>
> If the python script crash or raise an error, blender will exit with a zero
> code, so the renderfarm is not catching something has been wrong.
>
> In the mean time, we have to do a try/except in our scripts and add
> os._exit(0) or os._exit(-1) (_exit() because blender doesn't accept the
> exit()).
> We are wondering if this is the correct approach or if blender shouldn't
> return the code itself if the script didn't run correctly ?
>
>
> cheers,
>
> F.
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>



-- 
--
Diego Gangl - sinestesia.co


More information about the Bf-committers mailing list