Skip to content

Commit b356a5b

Browse files
committed
temp
1 parent 2d2b481 commit b356a5b

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

examples/topic/topic_transactions_example.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ def writer_example(driver: ydb.Driver, topic: str):
55
session_pool = ydb.QuerySessionPool(driver)
66

77
def callee(tx: ydb.QueryTxContext):
8-
tx_writer: ydb.TopicTxWriter = driver.topic_client.tx_writer(tx, topic)
9-
# нужно ли внутри ретраить ? нужно разрешать ретраи с дедупликацией
10-
# дефолт - без дедупликации, без ретраев и без producer_id. договорились.
8+
tx_writer: ydb.TopicTxWriter = driver.topic_client.tx_writer(tx, topic) # <=======
9+
# дефолт - без дедупликации, без ретраев и без producer_id.
1110

1211
with tx.execute(query="select 1") as result_sets:
1312
messages = [result_set.rows[0] for result_set in result_sets]
1413

15-
tx_writer.write(messages)
14+
tx_writer.write(messages) # вне зависимости от состояния вышестоящего стрима поведение должно быть одинаковое
1615

1716
session_pool.retry_tx_sync(callee)
1817

@@ -21,11 +20,9 @@ def reader_example(driver: ydb.Driver, reader: ydb.TopicReader):
2120
session_pool = ydb.QuerySessionPool(driver)
2221

2322
def callee(tx: ydb.QueryTxContext):
24-
batch = reader.receive_batch_with_tx(tx, max_messages=5)
23+
batch = reader.receive_batch_with_tx(tx, max_messages=5) # <=======
2524

2625
with tx.execute(query="INSERT INTO max_values(val) VALUES ($val)", parameters={"$val": max(batch)}) as _:
2726
pass
2827

29-
# коммитим при выходе из лямбды
30-
3128
session_pool.retry_tx_sync(callee)

0 commit comments

Comments
 (0)