How to control assignment order of a variable?

I finally troubleshot a difficult problem caused by this:
-Two different node trees use the same property; one sets the value and the other reads it.
-Turns out that reading happens BEFORE the setting.
How do I control the order of initializations? Numerous ways come to mind using properties as flags or sending events around in some kind of chain letter, neither of which appeals.
thanks

Hi, these situations are called “race conditions” in general programming. Like you mentioned, there are several ways to overcome this.

I just like to add a couple more to what you already thought of:

  1. Export the trait but don’t add it to the object. In the other trait, after initializing the variable add the trait.

    On Init -> Set Property -> Add Trait
    
  2. Use the Scene as the object. Then, you can set the default start value to this object in Blender UI. Then, both the traits can refer to this property.

The issue is not that both the traits access the same property. It is that they do both seem to read and write at On Init. So changing this logic might also help.

I am unaware of the larger picture, so this is the best suggestions I can come up with. Given a more broader scope of the problem, there might be simpler solutions to deal with these race conditions.

thanks for the advice, I will look into your approach. As you said, my architecture is unknown to you and I haven’t had enough experience to know how to set up my project well (I’m used to writing software with UIs and such but those are more linear.) Also, I’m trying to keep all of my initializations to one place as a goto when I need to modify something. I could use the defaults values in the properties for an object but the list was getting too long and too much scrolling so I broke it up into multiple objects for different functions so now have race conditions and inter-tree interactions.

Not sure if this is still relevant for you but you can use this node to for tasks to be executed in a given order.