You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The InMemoryBackingStore class is experiencing an infinite loop when setting values. This occurs because the set method subscribes a lambda function that calls set again, which in turn triggers the subscription callback, causing set to be called repeatedly.
ifisinstance(value, list):
# if its a collection, subscribe to the collection's item BackingStores and use# the events to flag the collection property is "dirty"foriteminvalue:
ifisinstance(item, BackedModel) anditem.backing_store:
item.backing_store.is_initialization_completed=Trueitem.backing_store.subscribe(
lambdaprop_key, old_val, new_val: self.set(key, value)
)
self.__store[key] =value_to_addforsubinlist(self.__subscriptions):
self.__subscriptions[sub](key, old_value, value_to_add)
Because you're invoking the subscription which is calling set which is invoking the subscription.
Expected behavior
The set method should store the value and notify subscribers without causing an infinite loop.
How to reproduce
Create an instance of InMemoryBackingStore.
Set a value that is a BackedModel or a list containing BackedModel instances.
The set method subscribes a lambda function that calls set again.
The subscription callback is triggered, causing set to be called repeatedly.
SDK Version
No response
Latest version known to work for scenario above?
No response
Known Workarounds
Awful, but until an update, unsubscribing and re-subscribing around problematic code.
subscription_ids= []
# Collect all backing stores and sub ids as to not modify while iteratingforroleinapp.app_roles:
ifisinstance(role, BackedModel) androle.backing_store:
for (
sub_id,
callback,
) inrole.backing_store._InMemoryBackingStore__subscriptions.items():
ifcallback.__name__=="<lambda>":
subscription_ids.append((role.backing_store, sub_id))
# Unsubscribe lambdas...forbacking_store, sub_idinsubscription_ids:
backing_store.unsubscribe(sub_id)
# Problematic codeforroleinapp.app_roles:
ifrole.is_enabled!=enable:
role.is_enabled=enable# Resubscribe lambdas...forbacking_store, sub_idinsubscription_ids:
backing_store.subscribe(
lambdaprop_key, old_val, new_val: role.backing_store.set(
prop_key, new_val
),
sub_id,
)
Debug output
Click to expand log
```
</details>
### Configuration
_No response_
### Other information
_No response_
The text was updated successfully, but these errors were encountered:
Describe the bug
The InMemoryBackingStore class is experiencing an infinite loop when setting values. This occurs because the set method subscribes a lambda function that calls set again, which in turn triggers the subscription callback, causing set to be called repeatedly.
Because you're invoking the subscription which is calling set which is invoking the subscription.
Expected behavior
The set method should store the value and notify subscribers without causing an infinite loop.
How to reproduce
SDK Version
No response
Latest version known to work for scenario above?
No response
Known Workarounds
Awful, but until an update, unsubscribing and re-subscribing around problematic code.
Debug output
Click to expand log
```The text was updated successfully, but these errors were encountered: