hou.InteruptableOperation outside of a with statement?

   3126   2   0
User Avatar
Member
85 posts
Joined: Aug. 2010
Offline
Hi there

I am trying to create a generic progress bar so have been looking at hou.InteruptableOperation

My conundrum is that due to in-house generic pipeline tools that implement this for all packages (including maya and softimage), I need to separate out the progress bar into 3 stages:

Creation

Update

Exit


The docs state not to call this class unless I am within a ‘with’ statement. This makes the separation of these stages very difficult

I am attempting to call the __enter__ and __exit__ methods directly but am not having much luck

Could someone give me a pointer about how to achieve this?

Many thanks!
Sam Swift-Glasman
Art Director
Five AI
User Avatar
Member
85 posts
Joined: Aug. 2010
Offline
answer from SESI:

Hello Sam,

It sounds like you should set the long operation name/message in hou.InterruptableOperation in order to update the progress bar dialog with message updates.

For example:
# Create an interruptable operation.
operation = hou.InterruptableOperation(“Doing Work”, long_operation_name=“Starting Tasks”, open_interrupt_dialog=True)

# Start the operation. This will pop-up the progress bar dialog after a second or two.
operation.__enter__()

# Execute tasks. Periodically update the progress percentage and message in the progress bar.
num_tasks = 10
for i in range(num_tasks):
# Do task work here. For this example, just sleep for a second.
time.sleep(1)

percent = float(i) / float(num_tasks)
operation.updateLongProgress(percent, “Finished task %i” % (i + 1))

# Stop the operation. This closes the progress bar dialog.
operation.__exit__(None, None, None)

I hope this helps.
Sam Swift-Glasman
Art Director
Five AI
User Avatar
Member
8 posts
Joined: Aug. 2014
Offline
Thanks for posting this. This is very helpful right now. I'm trying to do InterruptableOperation in a thread to cancel multiple submission jobs to the farm.
  • Quick Links