Skip to content

fix: script pull abort and async generator cleanup#212

Merged
KadirBalku merged 2 commits intoviur-framework:mainfrom
sveneberth:fix/script-pull-asyncio
May 5, 2026
Merged

fix: script pull abort and async generator cleanup#212
KadirBalku merged 2 commits intoviur-framework:mainfrom
sveneberth:fix/script-pull-asyncio

Conversation

@sveneberth
Copy link
Copy Markdown
Member

@sveneberth sveneberth commented May 5, 2026

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

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 aborting

sveneberth added 2 commits May 5, 2026 16:37
…n()`

`asyncio.new_event_loop().run_until_complete()` skips
`shutdown_asyncgens()`, so async generators (e.g. `TreeModule.list`)
that are not fully exhausted have their `aclose()` scheduled but never
awaited. This produces a `RuntimeWarning` on Python 3.12+ and causes
functional breakage on Python 3.14.

`asyncio.run()` calls `loop.shutdown_asyncgens()` before closing,
fixing the cleanup.
When `click.confirm()` receives an EOF (non-interactive stdin) or the
user presses Ctrl+C, it raises `click.exceptions.Abort`. Previously
this propagated out of `process_entry` and aborted the entire pull,
leaving all remaining files unpulled.

Catch the exception per-file and skip to the next entry instead.
@sveneberth sveneberth added bug Something isn't working Priority: Medium This issue may be useful, and needs some attention. labels May 5, 2026
@sveneberth sveneberth changed the title fix: script pull abort and async generator cleanup on Python 3.12+ fix: script pull abort and async generator cleanup May 5, 2026
Copy link
Copy Markdown
Collaborator

@KadirBalku KadirBalku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks fine so far thank you

@KadirBalku KadirBalku merged commit 8c79328 into viur-framework:main May 5, 2026
@sveneberth sveneberth deleted the fix/script-pull-asyncio branch May 5, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Priority: Medium This issue may be useful, and needs some attention.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants