Commit 8c79328
authored
fix:
## Problems
**1. `new_event_loop().run_until_complete()` skips async generator
cleanup**
As the Python docs note:
> "consider using the higher-level `asyncio.run()` function, instead of
using these lower level functions to manually create and close an event
loop." — [asyncio event
loop](https://docs.python.org/3/library/asyncio-eventloop.html)
`asyncio.run()` additionally calls `loop.shutdown_asyncgens()` before
closing, which `run_until_complete()` does not.
Async generators (e.g. `TreeModule.list`) that are not fully exhausted
have their `aclose()` scheduled but never awaited, producing a
`RuntimeWarning`.
**2. `click.Abort` during overwrite prompt aborts the entire pull**
`click.confirm()` raises `click.exceptions.Abort` when it receives EOF
(non-interactive stdin, e.g. scripts or some IDEs) or the user presses
Ctrl+C.
Previously this propagated uncaught out of `process_entry`, aborting the
whole pull and leaving all remaining files unpulled.
## Fixes
- Replace all `asyncio.new_event_loop().run_until_complete()` calls with
`asyncio.run()` (`get_modules`, `pull`, `push`, `run`)
- Catch `click.exceptions.Abort` per file in `script pull` and skip to
the next entry instead of abortingscript pull abort and async generator cleanup (#212)1 parent 5f3694f commit 8c79328
1 file changed
Lines changed: 12 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
149 | | - | |
150 | | - | |
151 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
152 | 155 | | |
153 | 156 | | |
154 | 157 | | |
| |||
161 | 164 | | |
162 | 165 | | |
163 | 166 | | |
164 | | - | |
| 167 | + | |
165 | 168 | | |
166 | 169 | | |
167 | 170 | | |
| |||
313 | 316 | | |
314 | 317 | | |
315 | 318 | | |
316 | | - | |
| 319 | + | |
317 | 320 | | |
318 | 321 | | |
319 | 322 | | |
| |||
341 | 344 | | |
342 | 345 | | |
343 | 346 | | |
344 | | - | |
| 347 | + | |
345 | 348 | | |
346 | | - | |
| 349 | + | |
347 | 350 | | |
348 | 351 | | |
349 | 352 | | |
| |||
376 | 379 | | |
377 | 380 | | |
378 | 381 | | |
379 | | - | |
| 382 | + | |
0 commit comments