Skip to content

feat: add timeout parameter to Python API functions#597

Merged
dionhaefner merged 4 commits into
mainfrom
dion/timeout
May 22, 2026
Merged

feat: add timeout parameter to Python API functions#597
dionhaefner merged 4 commits into
mainfrom
dion/timeout

Conversation

@dionhaefner

@dionhaefner dionhaefner commented May 19, 2026

Copy link
Copy Markdown
Contributor

Relevant issue or PR

n/a

Description of changes

In pathological cases, HTTP requests can hang forever (e.g. when a container runs out of memory or just hangs indefinitely). This is hard to detect and work around if it happens deep within a call stack. This PR introduces a timeout parameter to Tesseract.from_url and Tesseract.from_image so users can at least fail gracefully if requests hang.

Testing done

CI

@codecov

codecov Bot commented May 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.07%. Comparing base (f488e85) to head (f216f25).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #597      +/-   ##
==========================================
- Coverage   77.12%   77.07%   -0.06%     
==========================================
  Files          32       32              
  Lines        4489     4492       +3     
  Branches      738      738              
==========================================
  Hits         3462     3462              
- Misses        724      727       +3     
  Partials      303      303              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PasteurBot

PasteurBot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results

Benchmarks use a no-op Tesseract to measure pure framework overhead.

🚀 0 faster, ⚠️ 0 slower, ✅ 36 unchanged

✅ No significant performance changes detected.

Full results
Benchmark Baseline Current Change Status
api/apply_1,000 0.591ms 0.589ms -0.4%
api/apply_100,000 0.596ms 0.594ms -0.4%
api/apply_10,000,000 0.596ms 0.594ms -0.3%
cli/apply_1,000 1800.243ms 1828.309ms +1.6%
cli/apply_100,000 1780.141ms 1823.720ms +2.4%
cli/apply_10,000,000 1884.152ms 1792.643ms -4.9%
decoding/base64_1,000 0.037ms 0.037ms -0.4%
decoding/base64_100,000 0.698ms 0.672ms -3.6%
decoding/base64_10,000,000 67.601ms 68.103ms +0.7%
decoding/binref_1,000 0.205ms 0.205ms +0.2%
decoding/binref_100,000 0.248ms 0.245ms -1.3%
decoding/binref_10,000,000 10.736ms 10.789ms +0.5%
decoding/json_1,000 0.107ms 0.105ms -1.3%
decoding/json_100,000 8.839ms 9.122ms +3.2%
decoding/json_10,000,000 1065.030ms 1069.826ms +0.5%
encoding/base64_1,000 0.041ms 0.040ms -2.5%
encoding/base64_100,000 0.146ms 0.146ms +0.0%
encoding/base64_10,000,000 25.964ms 26.364ms +1.5%
encoding/binref_1,000 0.317ms 0.313ms -1.2%
encoding/binref_100,000 0.498ms 0.500ms +0.4%
encoding/binref_10,000,000 18.901ms 19.158ms +1.4%
encoding/json_1,000 0.150ms 0.148ms -0.9%
encoding/json_100,000 13.522ms 13.843ms +2.4%
encoding/json_10,000,000 1414.204ms 1404.026ms -0.7%
http/apply_1,000 3.264ms 3.417ms +4.7%
http/apply_100,000 9.980ms 10.286ms +3.1%
http/apply_10,000,000 770.868ms 782.852ms +1.6%
roundtrip/base64_1,000 0.087ms 0.087ms -0.8%
roundtrip/base64_100,000 0.733ms 0.739ms +0.8%
roundtrip/base64_10,000,000 93.698ms 93.752ms +0.1%
roundtrip/binref_1,000 0.541ms 0.544ms +0.6%
roundtrip/binref_100,000 0.739ms 0.742ms +0.5%
roundtrip/binref_10,000,000 29.814ms 29.831ms +0.1%
roundtrip/json_1,000 0.270ms 0.268ms -0.7%
roundtrip/json_100,000 19.949ms 20.280ms +1.7%
roundtrip/json_10,000,000 2484.432ms 2467.303ms -0.7%
  • Runner: Linux 6.17.0-1013-azure x86_64

Comment thread tesseract_core/sdk/tesseract.py Outdated
Comment thread tests/endtoend_tests/test_tesseract_sdk.py
@dionhaefner

Copy link
Copy Markdown
Contributor Author

@apaleyes done

@dionhaefner
dionhaefner enabled auto-merge (squash) May 22, 2026 11:03
@dionhaefner
dionhaefner merged commit 08a5bf0 into main May 22, 2026
52 checks passed
@dionhaefner
dionhaefner deleted the dion/timeout branch May 22, 2026 11:03
@pasteurlabs pasteurlabs locked and limited conversation to collaborators May 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants