Writing into Table with Stream.take() not allowed

Đang mở
#497 15 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
18/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
stream-processing

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
Python
Star
1.9k
Fork
205
Merge trung bình
2 giờ 2 phút
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của faust-streaming/faust

Tất cả issue của faust-streaming/faust

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.