<viztask>.returnValue

Exit current task and set a return value

 

<viztask>.returnValue(
    value    

)

 

value

The return value object


Remarks

When called inside a task function, this command will set a return value and stop the task. The return value is available to the parent task that yielded the sub-task.

Task functions are implemented using Python generators, which don't allow return values. This command works around this limitation by raising a special exception that stores the return value. The viztask module will handle this exception and return the value to the parent task.

NOTE: Since this command raises an exception to return the value, you should not call this command within a try/except block

Return Value

None

Example

def waitForIt():
    d = yield viztask.waitKeyDown(None)
    viztask.returnValue('Key: {0}'.format(d.key))
    print 'this line will not be reached'
   
def main():
    while True:

        it = yield waitForIt()
        print it

viztask.schedule(main())