Saving large files

I have an extractor that saves the Maya scene, before any other extractors.

When I have a file that is large in size and takes a long time to save, Pyblish exists/crashes without any errors.

Are there any timeouts that could have an influence on this?

Hmm, not that I can think of.

I will have a closer look tomorrow morning.

Ok, got it.

Apparently, it looks like Pyblish is “Quitting due to loneliness” when Maya takes too long (5+ seconds) to save a file. That is odd, as the loneliness is based on a separate thread making calls to Pyblish at regular intervals (called heartbeats) and threads shouldn’t be disrupted by saving.

I’ll have a think about this, the easiest thing to do would be to increase the threshold, to something like 30 seconds, or simply never shut down.

There’s no way to configure this at the moment, but you can subclass Pyblish QML an override this.

If you make a variable out of the 5 and make it a higher number, that should resolve your issue. If it works, we could have a look at making it configurable.

Here’s something recreatable.

import pyblish.api

class C(pyblish.api.Collector):
    def process(self, context):
        context.create_instance("MyInstance", family="all")

class V(pyblish.api.Validator):
    def process(self, instance):

        # Create heavy scene
        c = cmds.polyCube(sx=1000, sy=1000, sz=1000)
        cmds.delete(c, ch=True)

        maya.cmds.file(rename="temp.ma")
        maya.cmds.file(save=True)

pyblish.api.register_plugin(C)
pyblish.api.register_plugin(V)

import pyblish_maya
pyblish_maya.show()

Running this causes Maya to do work for at least 5 seconds, at which point you can see in the QML console that it quits due to loneliness.

Working on a fix now.

Here’s a standalone test.

# Server - Run from terminal
import time
import SimpleXMLRPCServer as Server

s = Server.SimpleXMLRPCServer(("127.0.0.1", 8000))

def f():
    print("I'm alive at: %s" % time.time())

s.register_function(f)
s.serve_forever()
# Client - Run from within the Maya Script Editor
import time
import xmlrpclib
import threading

p = xmlrpclib.ServerProxy("http://127.0.0.1:8000")

def heartbeat():
    while True:
        try:
            time.sleep(1)
            p.f()
        except:
            pass

threading.Thread(target=heartbeat).start()

# Create heavy scene
from maya import cmds
for x in range(10):
    c = cmds.polyCube(sx=1000, sy=1000, sz=1000)
    cmds.delete(c)

This also causes the server to stop receiving messages during the point at which Maya is busy building geometry.

This is a major flaw in the design and I’m quite frankly surprised it hasn’t come up sooner. :S Will have to consider a better solution to the problem of having Pyblish self-destruct when a host is no longer available. Possibly by simply not self-destructing, and residing in the tray permanently. There, it won’t be an invisible background process as it is currently.

Gave this a quick test in Nuke, which didn’t seem to have this problem when rendering or writing out files. It’s possible it only affects Maya; threads should really not be blocked under any circumstance, that’s what threads are for. It seems Maya doesn’t seem to adhere to this rule.

I’ve updated Pyblish QML, but not yet Pyblish for Windows.

You can fetch the update manually from here.

Use it like this.

# Set this as early as possible, ideally userSetup.py,
# or alternatively just before showing the GUI.
import pyblish_qml
pyblish_qml.settings.HeartbeatInterval = 120

The heartbeat interval was changed from 5 seconds to 60 seconds, should suffice under most circumstances.

In the future, I’ll remove the heartbeat altogether in favour of a tray icon from which you can inspect both the aliveness of Pyblish along with the console.

1 Like

It also struck me that this doesn’t happen if you have two hosts running at the same time, as then Pyblish wouldn’t be “lonely”. So that’s another way of keeping it open. :slight_smile:

I can confirm that this is working:)

I had a scene that was quitting. Replace the module in pyblish-x and published successfully.

1 Like