Commit 803887d
Review
fix(ex_app): bridge sync logger and model-fetch task to async NextcloudApp
After Phase 2 made ``NextcloudApp.log`` and ``NextcloudApp.set_init_status`` async,
two ExApp helpers kept calling them as if they were sync — silently producing
``RuntimeWarning: coroutine '...' was never awaited`` and dropping the operation
entirely. ``setup_nextcloud_logging`` is supposed to stream every Python log
record into ``nextcloud.log``, and ``fetch_models_task`` is the default ``/init``
handler that reports model-download progress back to AppAPI; both were no-ops.
logger.py
* Capture the running event loop at ``setup_nextcloud_logging`` time and stash
it on the handler. ``logging.Handler.emit`` is sync and can be called from
any thread, so each record is dispatched to the captured loop with
``asyncio.run_coroutine_threadsafe``. Fire-and-forget, since logging must
not block the caller. If the function is invoked outside a running loop
(no-async setup), an inert handler is installed.
integration_fastapi.py
* ``fetch_models_task`` gains an optional ``loop`` parameter and is wrapped
by a small ``_ProgressReporter`` that schedules ``set_init_status`` on the
captured loop and waits with a 30s timeout for ordered progress updates.
* The ``/init`` handler now captures ``asyncio.get_running_loop()`` and
forwards it to the BackgroundTasks worker thread, where there is no loop
of its own.
* Inner ``__fetch_model_as_file`` / ``__fetch_model_as_snapshot`` accept the
reporter callable in place of the bare ``NextcloudApp`` and use it for
every progress tick.
Bumps the version to 0.31.0.dev0 and adds a CHANGELOG entry covering the breaking
sync removal, these regressions, and the conftest event-loop reset.1 parent 65cbca3 commit 803887d
4 files changed
Lines changed: 104 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
5 | 18 | | |
6 | 19 | | |
7 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
111 | | - | |
| 112 | + | |
| 113 | + | |
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
| |||
132 | 134 | | |
133 | 135 | | |
134 | 136 | | |
135 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
136 | 143 | | |
137 | 144 | | |
138 | 145 | | |
| |||
155 | 162 | | |
156 | 163 | | |
157 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
158 | 169 | | |
159 | 170 | | |
160 | 171 | | |
161 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
162 | 179 | | |
163 | 180 | | |
164 | 181 | | |
165 | 182 | | |
166 | 183 | | |
167 | 184 | | |
168 | 185 | | |
169 | | - | |
| 186 | + | |
170 | 187 | | |
171 | 188 | | |
172 | 189 | | |
173 | | - | |
| 190 | + | |
174 | 191 | | |
175 | 192 | | |
176 | 193 | | |
177 | | - | |
| 194 | + | |
178 | 195 | | |
179 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
180 | 220 | | |
181 | 221 | | |
182 | 222 | | |
183 | | - | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
184 | 228 | | |
185 | 229 | | |
186 | 230 | | |
| |||
209 | 253 | | |
210 | 254 | | |
211 | 255 | | |
212 | | - | |
| 256 | + | |
213 | 257 | | |
214 | 258 | | |
215 | 259 | | |
| |||
222 | 266 | | |
223 | 267 | | |
224 | 268 | | |
225 | | - | |
| 269 | + | |
226 | 270 | | |
227 | 271 | | |
228 | 272 | | |
| |||
238 | 282 | | |
239 | 283 | | |
240 | 284 | | |
241 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
242 | 290 | | |
243 | 291 | | |
244 | 292 | | |
| |||
252 | 300 | | |
253 | 301 | | |
254 | 302 | | |
255 | | - | |
| 303 | + | |
256 | 304 | | |
257 | 305 | | |
258 | 306 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
23 | 33 | | |
| 34 | + | |
24 | 35 | | |
25 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
26 | 40 | | |
27 | 41 | | |
28 | 42 | | |
29 | 43 | | |
30 | 44 | | |
31 | 45 | | |
32 | 46 | | |
33 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
34 | 51 | | |
35 | 52 | | |
36 | 53 | | |
37 | 54 | | |
38 | 55 | | |
39 | 56 | | |
40 | 57 | | |
41 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
42 | 69 | | |
43 | | - | |
| 70 | + | |
44 | 71 | | |
45 | 72 | | |
46 | 73 | | |
0 commit comments