Skip to content

Commit

Permalink
fix: handle RuntimeError when checking if we can use pdf split mode (#…
Browse files Browse the repository at this point in the history
…145)

Certain environments throw a `RuntimeError: There is no current event
loop in thread 'asyncio_0'` when we try to check if we're able to use
the splitting code. In this case, return False so we can fallback to non
split mode.

Once this is merged, I can regenerate the client to publish 0.25.4.
  • Loading branch information
awalker4 authored Aug 6, 2024
1 parent f927744 commit f9cc36f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/unstructured_client/_hooks/custom/split_pdf_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def context_is_uvloop():
import uvloop # pylint: disable=import-outside-toplevel
loop = asyncio.get_event_loop()
return isinstance(loop, uvloop.Loop)
except ImportError:
except (ImportError, RuntimeError):
return False

def get_optimal_split_size(num_pages: int, concurrency_level: int) -> int:
Expand Down

0 comments on commit f9cc36f

Please sign in to comment.