This is an automated email from the ASF dual-hosted git repository.

kszucs pushed a commit to branch maint-6.0.x
in repository https://gitbox.apache.org/repos/asf/arrow.git

commit a0a1ff1c11d761f964174e00508fc03d1a11cca0
Author: Antoine Pitrou <[email protected]>
AuthorDate: Thu Nov 4 12:03:05 2021 +0100

    ARROW-14437: [Python] Make CSV cancellation test more robust
    
    Size the workload according to the machine speed, to increase the 
probability of actually triggering cancellation.
    
    Closes #11598 from pitrou/ARROW-14437-csv-cancellation-test
    
    Authored-by: Antoine Pitrou <[email protected]>
    Signed-off-by: Krisztián Szűcs <[email protected]>
---
 python/pyarrow/tests/test_csv.py | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/python/pyarrow/tests/test_csv.py b/python/pyarrow/tests/test_csv.py
index 8fd62bb..b6cca24 100644
--- a/python/pyarrow/tests/test_csv.py
+++ b/python/pyarrow/tests/test_csv.py
@@ -1321,8 +1321,17 @@ class BaseCSVTableRead(BaseTestCSV):
         raise_signal = util.get_raise_signal()
 
         # Make the interruptible workload large enough to not finish
-        # before the interrupt comes, even in release mode on fast machines
-        large_csv = b"a,b,c\n" + b"1,2,3\n" * 200_000_000
+        # before the interrupt comes, even in release mode on fast machines.
+        last_duration = 0.0
+        workload_size = 100_000
+
+        while last_duration < 1.0:
+            print("workload size:", workload_size)
+            large_csv = b"a,b,c\n" + b"1,2,3\n" * workload_size
+            t1 = time.time()
+            self.read_bytes(large_csv)
+            last_duration = time.time() - t1
+            workload_size = workload_size * 3
 
         def signal_from_thread():
             time.sleep(0.2)
@@ -1340,8 +1349,9 @@ class BaseCSVTableRead(BaseTestCSV):
         except KeyboardInterrupt:
             # In case KeyboardInterrupt didn't interrupt `self.read_bytes`
             # above, at least prevent it from stopping the test suite
-            self.fail("KeyboardInterrupt didn't interrupt CSV reading")
+            pytest.fail("KeyboardInterrupt didn't interrupt CSV reading")
         dt = time.time() - t1
+        # Interruption should have arrived timely
         assert dt <= 1.0
         e = exc_info.value.__context__
         assert isinstance(e, pa.ArrowCancelled)

Reply via email to