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.
# 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.
# 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.
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.