Jump to content

[Solved] Getting list of active MPlay session from the main Houdini process?


violalyu

Recommended Posts

Hi Houdini friends,

Does anyone tried or know, how to get a list of active MPlay sessions from the main Houdini process? Basically like a list of port - Mplay session pairs or the like, or even session labels. 
Thank you so much in advance!

Best,
Viola Lyu

Edited by violalyu
Link to comment
Share on other sites

3 minutes ago, malexander said:

You can determine which mplay sessions Houdini is linked to for flipbooking and rendering by looking at $HOME/houdiniX.Y/.flipbook_lock.<hostname> and .mplay_lock.<hostname> (if they exist). The first number is the process ID of the connected mplay session.

Hi Mark,

Thank you so much for the reply! I didn't have the .mplay_lock files existing, .flipbook_lock files do exist.


I think the situation here is a little bit different, where the actual scenario here is, I was trying to launch an MPlay session with a given env dict where I stored some information I need in the environment variable via a subprocess.Popen in a dialog I created, and then I was calling the sceneviewer.flipbook() but with the desired settings passes in, so the session label matches the one I brought up, so that I can do things in the MPlay menu item etc. What I've noticed is that, sometimes the MPlay session I brought up may not been connected to the main Houdini process when the flipbook() is executed, so the flipbook() created its own MPlay session and that got the priority so the original one (the one I created before hand) got deleted, and I don't have the desired environment variable anymore. 

I was trying to see if there's a way that we can avoid this racing situation, other than have a magic number of sleep before the flipbook() runs. Is the .mplay_lock file created after it starts to listen to a flipbook session? 

Thank you sooooooo much again for the reply!

Link to comment
Share on other sites

Yep, that sounds like a race condition. Have you tried just setting the env variables in python (putenv)? When Houdini spawns MPlay, MPlay inherits all the environment variables that were set. Otherwise I suppose you could wait until the .flipbook_lock file appears, and then run the flipbook, as it's MPlay that creates the lockfile.

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, malexander said:

Yep, that sounds like a race condition. Have you tried just setting the env variables in python (putenv)? When Houdini spawns MPlay, MPlay inherits all the environment variables that were set. Otherwise I suppose you could wait until the .flipbook_lock file appears, and then run the flipbook, as it's MPlay that creates the lockfile.

Hi Mark,

Thank you so much for the reply!

The first part for setting env variables via hou.putenv(), I thought about that at first, then I realized that this would not work for multiple MPlay sessions parented under the same Houdini session( for example, user flipbooked from one angle, and then want to decide if they want to save/publish later, and they flipbooked from another angle/viewport, then we have 2 MPlay parented to this Houdini process,), unless we have a way in Mplay context to know which session it is in, we cannot distinguish which information is associated to which even if we serialized a dictionary and save it to Houdini env, or maybe you know how that could be achieved? Because as far as I know, the MPlay python exec seems to be running as a hython process? and doesn't have any context of the houdini session (nodes etc.) not even hou.ui is availble at that level...

AND, I think you are absolutely right about the lock file part, it did created a lock file when it launched, before any flipbook call. I guess that is the mark of the socket connection finished? But thank you soooooooooooo much Mark, I think this is enough to confirm that the mplay session exists! This is really really helpful for me!

Best,
Viola Lyu

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...