Skip to content

Commit

Permalink
Workaround for segfault likely caused by CPython
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonspeed committed Jan 9, 2025
1 parent 046eb93 commit 225be09
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion py-polars/tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import random
import string
import sys
import time
import tracemalloc
from typing import TYPE_CHECKING, Any, cast

Expand Down Expand Up @@ -205,7 +206,11 @@ def get_peak(self) -> int:
return tracemalloc.get_traced_memory()[1]


@pytest.fixture
# The bizarre syntax is from
# https://github.com/pytest-dev/pytest/issues/1368#issuecomment-2344450259 - we
# need to mark any test using this fixture as slow because we have a sleep
# added to work around a CPython bug, see the end of the function.
@pytest.fixture(params=[pytest.param(0, marks=pytest.mark.slow)])
def memory_usage_without_pyarrow() -> Generator[MemoryUsage, Any, Any]:
"""
Provide an API for measuring peak memory usage.
Expand Down Expand Up @@ -233,6 +238,9 @@ def memory_usage_without_pyarrow() -> Generator[MemoryUsage, Any, Any]:
finally:
tracemalloc.stop()

# Workaround for https://github.com/python/cpython/issues/128679
time.sleep(1)


@pytest.fixture(params=[True, False])
def test_global_and_local(
Expand Down

0 comments on commit 225be09

Please sign in to comment.