westonpace commented on a change in pull request #11294:
URL: https://github.com/apache/arrow/pull/11294#discussion_r731338879



##########
File path: python/pyarrow/tests/test_dataset.py
##########
@@ -422,6 +422,42 @@ def test_scanner(dataset, dataset_reader):
     assert table.num_rows == scanner.count_rows()
 
 
+def test_scanner_backpressure():
+    batch = pa.record_batch([pa.array([1, 2, 3])], names=['data'])
+    num_read = 0
+    min_read = 64  # From kDefaultBackpressureHigh in scanner.h
+    end = 200
+
+    def counting_generator():
+        nonlocal num_read
+        while num_read < end:
+            time.sleep(0.01)
+            num_read += 1
+            yield batch
+
+    scanner = ds.Scanner.from_batches(
+        counting_generator(), batch.schema, use_threads=True, use_async=True)
+
+    _batch_iter = scanner.to_batches()  # This line starts the scan
+
+    start = time.time()
+
+    def duration():
+        return time.time() - start
+
+    last_num_read = 0
+    backpressure_probably_hit = False
+    while duration() < 10:
+        if num_read > min_read and num_read == last_num_read:
+            backpressure_probably_hit = True
+            break
+        last_num_read = num_read
+        time.sleep(0.5)

Review comment:
       The test has been removed.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to