This is an automated email from the ASF dual-hosted git repository.
raulcd pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new 54f8cf9d96 GH-44728: [Python] Trigger manual Garbage collection before
checking allocated bytes for dlpack tests (#44793)
54f8cf9d96 is described below
commit 54f8cf9d969b1a1f668c4102a26df57282bc977c
Author: Raúl Cumplido <[email protected]>
AuthorDate: Thu Nov 21 09:04:59 2024 +0100
GH-44728: [Python] Trigger manual Garbage collection before checking
allocated bytes for dlpack tests (#44793)
### Rationale for this change
test_dlpack started failing for several jobs on CI due to our tests
deallocating memory:
```
allocated_bytes = pa.total_allocated_bytes()
try:
return f(*args, **kwargs)
finally:
> assert pa.total_allocated_bytes() == allocated_bytes
E assert 3728 == 7440
```
### What changes are included in this PR?
Trigger a `gc.collect` before checking initial allocated bytes.
### Are these changes tested?
Yes via CI
### Are there any user-facing changes?
No
* GitHub Issue: #44728
Authored-by: Raúl Cumplido <[email protected]>
Signed-off-by: Raúl Cumplido <[email protected]>
---
python/pyarrow/tests/test_dlpack.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/python/pyarrow/tests/test_dlpack.py
b/python/pyarrow/tests/test_dlpack.py
index a18accb1e2..c00290e01a 100644
--- a/python/pyarrow/tests/test_dlpack.py
+++ b/python/pyarrow/tests/test_dlpack.py
@@ -17,6 +17,7 @@
import ctypes
from functools import wraps
+import gc
import pytest
try:
@@ -50,6 +51,7 @@ def check_dlpack_export(arr, expected_arr):
def check_bytes_allocated(f):
@wraps(f)
def wrapper(*args, **kwargs):
+ gc.collect()
allocated_bytes = pa.total_allocated_bytes()
try:
return f(*args, **kwargs)