Skip to content

Commit c696740

Browse files
committed
Try passing use_threads in pyarrow again
1 parent 11ad11d commit c696740

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

pandas/tests/io/parser/conftest.py

+14-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
)
1313
import pandas._testing as tm
1414

15+
from pandas.io.parsers import readers
16+
from pandas.io.parsers.arrow_parser_wrapper import ArrowParserWrapper
17+
1518

1619
class BaseParser:
1720
engine: str | None = None
@@ -101,20 +104,24 @@ def csv1(datapath):
101104

102105

103106
@pytest.fixture(params=_all_parsers, ids=_all_parser_ids)
104-
def all_parsers(request):
107+
def all_parsers(request, monkeypatch):
105108
"""
106109
Fixture all of the CSV parsers.
107110
"""
108111
parser = request.param()
109112
if parser.engine == "pyarrow":
110113
pytest.importorskip("pyarrow", VERSIONS["pyarrow"])
111-
# Try setting num cpus to 1 to avoid hangs on Azure MacOS/Windows builds
112-
# or better yet find a way to disable threads
113-
# TODO(GH#44584) pytest.mark.single these tests
114-
import pyarrow
115114

116-
pyarrow.set_cpu_count(1)
117-
return parser
115+
class NoThreadArrowParserWrapper(ArrowParserWrapper):
116+
def _get_pyarrow_options(self):
117+
super()._get_pyarrow_options()
118+
self.read_options["use_threads"] = False
119+
120+
with monkeypatch.context() as m:
121+
m.setattr(readers, "ArrowParserWrapper", NoThreadArrowParserWrapper)
122+
yield parser
123+
else:
124+
yield parser
118125

119126

120127
@pytest.fixture(params=_c_parsers_only, ids=_c_parser_ids)

0 commit comments

Comments
 (0)