Vizard 7 » Command Index » Vizard modules » viztask » <viztask>.waitDirector
7.6

<viztask>.waitDirector

Wait for a director function to complete

<viztask>.waitDirector(  
func  
*args  
)  
func
The director function to execute
*args
Optional arguments to pass to director function

Remarks

This command will create a Condition object that will wait for the specified director function to complete.

The yielded command returns a viz.Data object with the following information about the condition:

Properties

returnValue

The return value of the director function

Return Value

viztask.Condition object

Example

import viztask

#Define a function that returns the last line of a text file
def getLast():
    file = open('data.txt', 'r')    
   
    for line in file:
        last = line
   
    file.close()

    return last 
                   
def fileTask():
   
    yield viztask.waitKeyDown(' ')
    viz.logNotice('Started file operation')
   
    #Execute the getLast function in a separate thread
    #and wait for it to complete and return some data
    data = yield viztask.waitDirector(getLast)
   
    viz.logNotice('Finished file operation, last line is: ',data.returnValue)

viztask.schedule( fileTask() )