AWS Thinkbox Discussion Forums

How to access local temp folder threadnumber?

Hi, I am trying to “Browse local temp folder” from task panel in monitor but cant figure out how to get the folder mayaOutput_randomnumber which is from “mayaoutput_ + str(self.GetThreadNumber())” for the local render dir. I can get the dir folder up to jobdata\jobid\ but not sure how to get this mayaoutput – is there a way to get this for the selected task using script from deadline monitor?

Thanks

The GetThreadNumber() function only makes sense within the Deadline Worker, not in the Monitor.

A Deadline Worker can execute up to 16 threads in parallel, based on the Concurrent Tasks count set in the Job Properties. In order to avoid overwriting files between the Tasks being processed by the same Worker, some paths are being made unique by inserting the Thread Number in the path name. In the MayaBatch.py integration plugin for example, we do

self.TempThreadDirectory = self.CreateTempDirectory( "thread" + str(self.GetThreadNumber()) )

The function self.GetThreadNumber() is also used to set the GPU affinity for Redshift and some other renderers.

So the value returned by self.GetThreadNumber() is not random, it should match the Concurrent Task index which ranges from 0 to 15. If you don’t have Concurrent Tasks enabled and only a single thread, I would expect that value to be 0.

Hi @Bobo - thanks for the info, this is hackish but to explain what I am trying to do in monitor

    if has_admin(os.environ['USERNAME']):
    try:
        # Set the path to root of the local render node
        path = "\\\\" + IPAddress[0] + "\\C$\\Users\\" + userID + "\\AppData\\Local\\Thinkbox\\Deadline7\\slave\\"+ slaveNames[0] + "\\jobsData\\" + jobID + "\\"+mayaoutput_folder
        path = os.path.normpath(path)
        # Open Windows Explorer in the Monitor machine (client side), to access the C:\ folder
        os.startfile(path) 

How to get the mayaoutput_folder value for a task from monitor, or the whole local ouput path is already in the task property that i can call… i.e. task.localrenderdirectory etc ?

There isn’t a way to ask Deadline what the folder name is. There is a function to create the folder which the plugin script uses as I mentioned in the previous post, but no way to read it outside of the Worker (a.k.a. Slave).

But you can ask the folder you constructed what sub-folders it has.

The sub-folders will be prefixed with the thread% token, followed by _ and the random token. So if you are interested in Thread 0, all you have to do is find out which of the existing folders starts with “thread0_”…

I just run a Maya job with 3 concurrent tasks and got these 3 sub-folders of my job folder:

"C:\Users\bobop\AppData\Local\Thinkbox\Deadline10\slave\DESKTOP-4E76V9C\jobsData\5f486f548d565251385cf083\thread0_tempmxuPR0"
"C:\Users\bobop\AppData\Local\Thinkbox\Deadline10\slave\DESKTOP-4E76V9C\jobsData\5f486f548d565251385cf083\thread1_temp7WQom0"
"C:\Users\bobop\AppData\Local\Thinkbox\Deadline10\slave\DESKTOP-4E76V9C\jobsData\5f486f548d565251385cf083\thread2_tempZmzOG0"

So if you would check the sub-folders of the path “C:\Users\bobop\AppData\Local\Thinkbox\Deadline10\slave\DESKTOP-4E76V9C\jobsData\5f486f548d565251385cf083” you would get back

"thread0_tempmxuPR0"
"thread1_temp7WQom0"
"thread2_tempZmzOG0"

Then just use the (first?) one you want to build the path to open in the Explorer…

Thank you @Bobo – yes, thx. will use scandir :slight_smile:
cheers!

Privacy | Site terms | Cookie preferences