Commit 66385fa
fix(accent): degrade gracefully when OJAD is unavailable
OJAD (www.gavo.t.u-tokyo.ac.jp) outages made /MarkAccent/ hang for the
full global 10s timeout and then return HTTP 500, because get_ojad_result
re-raised the transport error and the pipeline turned it into a 500.
Pitch accent from OJAD only enriches the furigana result, so an OJAD
outage should not fail the whole request:
- ojad.py: add a short per-request timeout (connect=2s, read=5s) so a
down OJAD fails fast instead of hanging on the global 10s, and raise a
dedicated OJADUnavailableError on any httpx.HTTPError (connect/read
timeouts, connection errors, non-2xx status).
- pipeline.py: catch OJADUnavailableError and degrade to furigana-only
output (align_accent already emits accent_marking_type=0 for an empty
OJAD list) with status 200 and a warning, instead of 500.
- models.py: add an optional, backward-compatible `warning` field to
AccentResponse for degraded results.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 0c17733 commit 66385fa
3 files changed
Lines changed: 41 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
26 | 40 | | |
27 | 41 | | |
28 | 42 | | |
| |||
47 | 61 | | |
48 | 62 | | |
49 | 63 | | |
50 | | - | |
| 64 | + | |
51 | 65 | | |
52 | 66 | | |
53 | | - | |
54 | | - | |
55 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
56 | 72 | | |
57 | 73 | | |
58 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
46 | 59 | | |
47 | 60 | | |
48 | 61 | | |
49 | | - | |
| 62 | + | |
50 | 63 | | |
51 | 64 | | |
52 | 65 | | |
| |||
0 commit comments