InMemoryBackingStore infinite loop
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Comienza localizando la clase InMemoryBackingStore e inspeccionando su método set, especialmente la suscripción añadida para valores BackedModel y listas. Reproduce el problema con un BackedModel o una lista de instancias de BackedModel y sigue las notificaciones a los suscriptores. Se considera terminado cuando establecer el valor lo almacena y notifica a los suscriptores sin invocar set de forma recursiva ni entrar en un bucle infinito.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
if isinstance(value, list):
# if its a collection, subscribe to the collection's item BackingStores and use
# the events to flag the collection property is "dirty"
for item in value:
if isinstance(item, BackedModel) and item.backing_store:
item.backing_store.is_initialization_completed = True
item.backing_store.subscribe(
lambda prop_key, old_val, new_val: self.set(key, value)
)
self.__store[key] = value_to_add
for sub in list(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 iterating
for role in app.app_roles:
if isinstance(role, BackedModel) and role.backing_store:
for (
sub_id,
callback,
) in role.backing_store._InMemoryBackingStore__subscriptions.items():
if callback.__name__ == "<lambda>":
subscription_ids.append((role.backing_store, sub_id))
# Unsubscribe lambdas...
for backing_store, sub_id in subscription_ids:
backing_store.unsubscribe(sub_id)
# Problematic code
for role in app.app_roles:
if role.is_enabled != enable:
role.is_enabled = enable
# Resubscribe lambdas...
for backing_store, sub_id in subscription_ids:
backing_store.subscribe(
lambda prop_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_
- Lenguaje dominante
- Python
- Estrellas
- 634
- Forks
- 100
- Merge medio
- 23 h 18 min
- PR fusionados (30 d)
- 7
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoftgraph/msgraph-sdk-python
-
status:waiting-for-triage type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
microsoftgraph/msgraph-sdk-python#1628 ·
Los mantenedores suelen responder en 1 día
-
status:waiting-for-triage type:bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
microsoftgraph/msgraph-sdk-python#1570 ·
Los mantenedores suelen responder en 1 día
-
status:waiting-for-triage type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
microsoftgraph/msgraph-sdk-python#1563 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
kiota-dom-export.txt is large and included in the released packagePosiblemente ocupada @Fryguy la tomó hace 184 días. AbiertoNeeds: Attention :wave: type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
microsoftgraph/msgraph-sdk-python#1287 · 3 comentarios · 2 reacciones ·
Los mantenedores suelen responder en 1 día
-
status:waiting-for-triage type:feature
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
microsoftgraph/msgraph-sdk-python#1596 ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoftgraph/msgraph-sdk-python
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
trycua/hermes-cua-spaces#17 ·
-
area:codegen backend:hip bug direction:output good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
nautechsystems/nautilus_trader#5718 ·
Los mantenedores suelen responder en 1 día
-
[Bug]: reme CLI crashes when the running server used a relative config pathPosiblemente ocupada @nurlanmnn la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
agentscope-ai/ReMe#770 ·
Los mantenedores suelen responder en 1 día
-
Pi: paused model calls are reported as "not signed in" when the model's provider comes from an extensionPosiblemente ocupada @balcsida la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
microsoft/TokenEconomizer#288 ·
Los mantenedores suelen responder en 1 día