Skip to content

Commit 0778497

Browse files
committed
Clean up fsspec.py now that Python 3.8 was dropped
1 parent 782f1dd commit 0778497

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

src/uproot/source/fsspec.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -133,24 +133,10 @@ def chunks(
133133
self._num_requested_chunks += len(ranges)
134134
self._num_requested_bytes += sum(stop - start for start, stop in ranges)
135135

136-
try:
137-
# not available in python 3.8
138-
to_thread = asyncio.to_thread
139-
except AttributeError:
140-
import contextvars
141-
import functools
142-
143-
async def to_thread(func, /, *args, **kwargs):
144-
loop = asyncio.get_running_loop()
145-
ctx = contextvars.copy_context()
146-
func_call = functools.partial(ctx.run, func, *args, **kwargs)
147-
return await loop.run_in_executor(None, func_call)
148-
149136
async def async_wrapper_thread(blocking_func, *args, **kwargs):
150137
if not callable(blocking_func):
151138
raise TypeError("blocking_func must be callable")
152-
# TODO: when python 3.8 is dropped, use `asyncio.to_thread` instead (also remove the try/except block above)
153-
return await to_thread(blocking_func, *args, **kwargs)
139+
return await asyncio.to_thread(blocking_func, *args, **kwargs)
154140

155141
def submit(request_ranges: list[tuple[int, int]]):
156142
paths = [self._file_path] * len(request_ranges)

0 commit comments

Comments
 (0)