Commit cd05c6e
authored
fix: Configuration.add()/discard() write through model setter for persistence (#596)
In-place mutation of the OrderedSet returned by self.value lost state changes
when the model uses a deserializing property (e.g., Django model field backed
by a DB column). Each getter call returned a fresh object, the in-place
mutation modified a temporary, and the model was never updated.
Changed add() and discard() to create a new OrderedSet and assign via
self.value = new, which calls setattr on the model. This only affects
atomic_configuration_update=False (StateChart default); the atomic path
was never affected.
Benchmark impact: ~4-5% on parallel region events (~2µs per event),
negligible vs. callback execution in the same microstep.
Signed-off-by: Fernando Macedo <fernando.macedo@jusbrasil.com.br>1 parent 2476d20 commit cd05c6e
File tree
3 files changed
+570
-7
lines changed- statemachine
- tests
- examples
3 files changed
+570
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
110 | | - | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
| 119 | + | |
| 120 | + | |
123 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
124 | 126 | | |
125 | 127 | | |
126 | 128 | | |
| |||
0 commit comments