2
$\begingroup$

Blender, at least on Ubuntu, doesn't prevent the computer from entering sleep while rendering, thus borking the render and combined with a (driver) bug that disables CUDA after suspend, it makes a user's life miserable.

I'm opening this question in order to gather python scripts for various platforms that prevent computer sleep while rendering.

$\endgroup$

1 Answer 1

1
$\begingroup$

I was tired of having to disable/enable suspend every time so I wrote this addon, which works on Gnome3.

    # © Michael Demetriou 2017

    #    This program is free software: you can redistribute it and/or modify
    #    it under the terms of the GNU General Public License as published by
    #    the Free Software Foundation, either version 3 of the License, or
    #    (at your option) any later version.
    #
    #    This program is distributed in the hope that it will be useful,
    #    but WITHOUT ANY WARRANTY; without even the implied warranty of
    #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    #    GNU General Public License for more details.
    #
    #    You should have received a copy of the GNU General Public License
    #    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    bl_info = {
        "name": "Inhibit suspend while rendering - for gnome",
        "author": "Michael Demetriou",
        "version": (1, 0),
        "blender": (2, 78, 0),
        "description": "Inhibits system suspend while rendering",
        "warning": "",
        "wiki_url": "",
        "tracker_url": "https://gist.github.com/qwazix/290a25576f8c1f80cbc929f5a5d3f27e",
        "category": "System"}
    ###########################################################################

    import bpy
    import dbus
    from bpy.app.handlers import persistent

    cookie = 0
    _session_bus = dbus.SessionBus()
    _dbus_screensaver = _session_bus.get_object('org.gnome.SessionManager','/org/gnome/SessionManager')
    inhibit = _dbus_screensaver.get_dbus_method('Inhibit','org.gnome.SessionManager')
    uninhibit = _dbus_screensaver.get_dbus_method('Uninhibit','org.gnome.SessionManager')

    @persistent
    def render_pre_handler(dummy):
        global cookie
        cookie = inhibit("BlenderRendering",dbus.UInt32(0),"inhibiting",dbus.UInt32(4));

    @persistent
    def render_post_handler(dummy):
        global cookie
        uninhibit(dbus.UInt32(cookie));    

    def register():
        bpy.app.handlers.render_pre.append(render_pre_handler)
        bpy.app.handlers.render_post.append(render_post_handler)

    def unregister():
        bpy.app.handlers.render_pre.remove(render_pre_handler)
        bpy.app.handlers.render_post.remove(render_post_handler)

    if __name__ == "__main__":
        register()

You can post similar scripts for your platform with the goal of combining them in a multiplatform addon that could ship with blender.

$\endgroup$
4
  • $\begingroup$ macOS doesn't have this problem. It will sleep but still render. It wouldn't need this. $\endgroup$ Commented Jan 21, 2017 at 16:30
  • $\begingroup$ How is that even possible? Notice that this does not disable the screensaver, just the suspend function. $\endgroup$
    – qwazix
    Commented Jan 21, 2017 at 17:32
  • $\begingroup$ When the sleep comes after the screensaver, it doesn't stop the rendering. I don't know if that holds true for a directly triggered sleep. Also, this might not hold true on a laptop. $\endgroup$ Commented Jan 21, 2017 at 23:22
  • $\begingroup$ I understand sleep as "low powered state". Rendering can be anything but low power, esp. on GPU, that's why my surprise. I will try it on a macbook though and report. $\endgroup$
    – qwazix
    Commented Jan 22, 2017 at 9:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .