Writing into Table with Stream.take() not allowed

Abierto
#497 15 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
18/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python

Línea de trabajo

The error is raised in partition_for_key in faust/tables/base.py, reached from on_key_set in faust/tables/table.py when a table key is set inside an agent. Run the reproduction from the issue against a local Kafka and read how the stream context is tracked around stream.take(). Done means either the write succeeds inside take() or the maintainers document the intended pattern. The thread is old and the approach is undecided, so confirm direction before coding.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Steps to reproduce

When using the Stream.take() function I can not write into a Table but get the error Cannot modify table key from outside of stream iteration.

Can I just not write to tables when using take?

Example:

from faust import App

app = App(id="take-error-example")

topic = app.topic('orders')
table = app.Table('orders')

@app.agent(topic)
async def consumer(stream):
    async for values in stream.take(1):
        for value in values:
            table["key"] = "some value"
            yield value

Expected behavior

The key value pair should be written into the Table

Actual behavior

File ".../python3.10/site-packages/mode/utils/collections.py", line 652, in __setitem__
    self.on_key_set(key, value)
  File ".../python3.10/site-packages/faust/tables/table.py", line 77, in on_key_set
    fut = self.send_changelog(self.partition_for_key(key), key, value)
  File ".../python3.10/site-packages/faust/tables/base.py", line 314, in partition_for_key
    raise TypeError(
TypeError: Cannot modify table key from outside of stream iteration

Versions

  • Python version: 3.10.6
  • Faust version: 0.10.11
  • Operating system: MacOS 13
Lenguaje dominante
Python
Estrellas
1.9k
Forks
205
Merge medio
2 h 2 min
PR fusionados (30 d)
1

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de faust-streaming/faust

Todos los issues de faust-streaming/faust

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.