How to return whether or not Blender is currently rendering

I’m looking for a value that will return render context (is Blender currently rendering?) either a boolean or some other derived way of telling if Blender is rendering. I thought bpy.context should host something like this, but didn’t find anything. Thanks.

What about using the handlers ?

Interesting, I’ve never seen those before today. I was messing around with, render_cancel and so on, but every time I run them in the console I just get back empty list brackets. Not really sure which one to use or how I might get this to return a sign that Blender is rendering.

This is not how it’s work. As you can see at the beginning of the link, it’s just gonna call a function when the handler is applied. If you really want a value for your script, just use a global variable and modify it using handlers and their function “linked”.

Thanks. Here’s another simple example.

import bpy

def isRendering(scene):
    print("Blender is rendering")

One more thing. Can handlers not be appended initially in addons? I tried using:

from import persistent

but this did not work. I tried registering them in the register area of the code where classes and other things I append are taken care of, but this didn’t work either. I’m basically using this to change the display of a menu item so I also tried throwing them in a class which draws menus and this worked but obviously that’s bad because it causes the items to append 40 times or so (though I am achieving the desired effect).

Not sure what you are asking?!

you should basically append handlers in register() and remove them in unregister().

Maybe this is related?


That was the first thing I tried but for some reason it wouldn’t work. Only when run from the script editor and not as an addon. I’m using render_pr and render_post app handlers if anyone cares to see if they will initiate in an addon from there machine.

@SicutUnum, if isRendering handler will be appended before rendering starts each time, may consider remove it from handler list each time, to avoid to be appended multiple times.

import bpy

def isRendering(scene):
    print("Blender is rendering")

Very simple, logical solution grammer. Thank you. I’ll try that out.