Isotropix Forums

Race Condition after RenameItem

General Discussion about Isotropix and CG related topics

Race Condition after RenameItem

Unread postby nmoreno » Sat Jul 18, 2020 1:54 am

I ran into another race condition when creating a file reference to a really big usd file, and renaming it immediately after.

Code: Select all
ref = ix.cmds.CreateFileReference(ctx_path, [usd_file_path])
ix.cmds.RenameItem(ref, new_name)
# a lot more stuff that works with my renamed path


The code using the new reference itself works, but after my code is done running I get a lot of these warnings below and some of the geometry comes into the wrong position in space:

Code: Select all
warning: OfObjectFactory.get_item: Item 'ref_before_rename/some/nested/object' not found.



I am able to get it to import properly using File > Reference which does not give me all those warnings.
The only difference between this and my code seems to be that rename item and it is looking for the nested objects in the original ref that was created for it on CreateFileReference, and not the renamed ref.

How can I make it wait for the rename to happen, or update that inner reference before it starts looking for all those nested objects?
Is there a way to pass in the name that we want the object to be called on CreateFileReference maybe using a different function or add the parameter sometime in the future?

Thanks in advance!
nmoreno
 
Posts: 6
Joined: Fri Mar 27, 2020 3:09 am

Re: Race Condition after RenameItem

Unread postby ayanik » Sat Jul 18, 2020 7:03 pm

Use
Code: Select all
ix.application.check_for_events()
directly after your rename command to let it catch up.
ayanik
 
Posts: 91
Joined: Wed Nov 26, 2014 9:10 pm


Return to General Discussion
cron