Skip to content

Commit 7419651

Browse files
committed
Remove uvloop blockers
1 parent 35612e6 commit 7419651

File tree

2 files changed

+1
-14
lines changed

2 files changed

+1
-14
lines changed

_test_unstructured_client/integration/test_integration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ async def test_partition_async_processes_concurrent_files(client, doc_path):
188188

189189

190190
def test_uvloop_partitions_without_errors(client, doc_path):
191+
"""Test that we can use pdf splitting within another asyncio loop."""
191192
async def call_api():
192193
filename = "layout-parser-paper-fast.pdf"
193194
with open(doc_path / filename, "rb") as f:

src/unstructured_client/_hooks/custom/split_pdf_hook.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,6 @@ async def run_tasks(
117117
return sorted(results, key=lambda x: x[0])
118118

119119

120-
def context_is_uvloop():
121-
"""Return true if uvloop is installed and we're currently in a uvloop context. Our asyncio splitting code currently doesn't work under uvloop."""
122-
try:
123-
import uvloop # type: ignore[import] # pylint: disable=import-outside-toplevel
124-
loop = asyncio.get_event_loop()
125-
return isinstance(loop, uvloop.Loop)
126-
except (ImportError, RuntimeError):
127-
return False
128-
129-
130120
def get_optimal_split_size(num_pages: int, concurrency_level: int) -> int:
131121
"""Distributes pages to workers evenly based on the number of pages and desired concurrency level."""
132122
if num_pages < MAX_PAGES_PER_SPLIT * concurrency_level:
@@ -273,10 +263,6 @@ def before_request(
273263
logger.warning("HTTP client not accessible! Continuing without splitting.")
274264
return request
275265

276-
if context_is_uvloop():
277-
logger.warning("Splitting is currently incompatible with uvloop. Continuing without splitting.")
278-
return request
279-
280266
# This is our key into coroutines_to_execute
281267
# We need to pass it on to after_success so
282268
# we know which results are ours

0 commit comments

Comments
 (0)