Drughi Posted October 2, 2019 Share Posted October 2, 2019 (edited) Hi, sometimes Houdini crashes while caching out simulations. I would like to trigger an event when it crashes. My idea was to create a subprocess wich checks every 5 Minutes if my sim is running by looking up if Houdinis PID exists. Does that make sense or is there a better way? Is the subprocess still running even if Houdini has crashed? I have no experience with subprocesses maybe someone can help me. What i have so far: import os pid = os.getpid() # in subprocess if os.name == 'posix': def pid_exists(pid): """Check whether pid exists in the current process table.""" import errno if pid < 0: return False try: os.kill(pid, 0) except OSError as e: return e.errno == errno.EPERM else: return True else: def pid_exists(pid): import ctypes kernel32 = ctypes.windll.kernel32 SYNCHRONIZE = 0x100000 process = kernel32.OpenProcess(SYNCHRONIZE, 0, pid) if process != 0: kernel32.CloseHandle(process) return True else: return False if not pid_exists(pid): # Trigger Event Edited October 2, 2019 by Drughi Quote Link to comment Share on other sites More sharing options...
vtrvtr Posted October 2, 2019 Share Posted October 2, 2019 You should use a render manager of some kind, Tractor, Deadline, Hqueue etc. Many of them have functionality like this. The way you're doing it is a bit troublesome. Where are you running this from? If it's from Houdini for obvious reasons it won't work since the program will have crashed. If it's from some other shell, how will you get the correct pid? Also, Python is cool so it will work, but your morphing function definition isn't very usual. Usually you would take care of the OS difference inside the function (or have two different functions). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.