is it safe to operate on a different stack than th...
# automation-api
is it safe to operate on a different stack than the one currently selected?
Copy code
stack_1 = auto.select_stack(...)
stack_2 = auto.create_or_select_stack(...)  # currently selected stack
stack_1.refresh_config()  # ok to do this now?
stack_1_config = stack1.get_all_config()  # ok to do this now?
There is an issue from a few days back about working on two stacks in parallel (await / async stuff), but code like this where everything happens serially is fine.
You can flip back and forth between stacks as much as you like, in synchronous code.
👍 1
on a side note - would it be ok to use a node.cluster() to execute multiple stacks in parallell (as they would be in separate child processes)?
Further up this channel, maybe 3 or 4 days ago, there was a thread that mentioned a bit of shared internal memory ot config or something that caused problems when things were happening in parallel. I remember that @red-match-15116 was in the thread. And that's about all I know 🙂
So… the issue there was that
change the currently selected stack which is a global setting (for a workspace). If these commands are executed in parallel in the same workspace they can have unexpected results and lead to odd bugs. I believe that if they are operating on separate workspaces this would not be a problem.
right - and that's not related to memory, that's related to something disk-physical I presume (or some pulumi temp workdir) outside of the process? with a node.cluster() it creates seperate nodejs instances (with seperate pids and memory) - so was hoping that might be enough to isolate the runs.
Yes, I understand that. But even in those separate processes if you end up running these commands on the same workspace you will run into these issues. Because exactly as you said, it’s not about memory but the physical files on disk. Essentially I’m saying using node.cluster() should be fine just be aware of the gotchas. It will only bite in very specific situations.