Title: Bug: RuntimeError: Event loop is closed when quitting TUI · Issue #558 · cecli-dev/cecli · GitHub
Open Graph Title: Bug: RuntimeError: Event loop is closed when quitting TUI · Issue #558 · cecli-dev/cecli
X Title: Bug: RuntimeError: Event loop is closed when quitting TUI · Issue #558 · cecli-dev/cecli
Description: Description When attempting to quit the cecli TUI, a RuntimeError: Event loop is closed is raised, causing the application to crash. Steps to Reproduce Start cecli TUI Attempt to quit (e.g., by pressing q or Ctrl+C) The following traceba...
Open Graph Description: Description When attempting to quit the cecli TUI, a RuntimeError: Event loop is closed is raised, causing the application to crash. Steps to Reproduce Start cecli TUI Attempt to quit (e.g., by pre...
X Description: Description When attempting to quit the cecli TUI, a RuntimeError: Event loop is closed is raised, causing the application to crash. Steps to Reproduce Start cecli TUI Attempt to quit (e.g., by pre...
Opengraph URL: https://github.com/cecli-dev/cecli/issues/558
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug: RuntimeError: Event loop is closed when quitting TUI","articleBody":"## Description\nWhen attempting to quit the cecli TUI, a `RuntimeError: Event loop is closed` is raised, causing the application to crash.\n\n## Steps to Reproduce\n1. Start cecli TUI\n2. Attempt to quit (e.g., by pressing `q` or Ctrl+C)\n3. The following traceback appears:\n\n```\nWould you like to see what's new in this version? (Y)es/(N)o [Yes]: n\nStarting cecli TUI...\n╭─────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────────────────────────────────────╮\n│ C:\\Users\\PDitty\\AppData\\Roaming\\uv\\tools\\cecli-dev\\Lib\\site-packages\\cecli\\tui\\app.py:1291 in _do_quit │\n│ │\n│ 1288 │ ╭───────────────────────────────────── locals ──────────────────────────────────────╮ │\n│ 1289 │ def _do_quit(self): │ self = TUI(title='TUI', classes={'-dark-mode'}, pseudo_classes={'focus', 'dark'}) │ │\n│ 1290 │ │ \"\"\"Perform the actual quit after UI updates.\"\"\" ╰───────────────────────────────────────────────────────────────────────────────────╯ │\n│ ❱ 1291 │ │ self.worker.stop() │\n│ 1292 │ │ self.exit() │\n│ 1293 │ │\n│ 1294 │ def run_obstructive(self, func, *args, **kwargs): │\n│ │\n│ C:\\Users\\PDitty\\AppData\\Roaming\\uv\\tools\\cecli-dev\\Lib\\site-packages\\cecli\\tui\\worker.py:190 in stop │\n│ │\n│ 187 │ │ │ # We'll just pass to allow the thread to exit gracefully ╭────────────────────────────── locals ──────────────────────────────╮ │\n│ 188 │ │ │ # without a scary traceback. │ self = \u003ccecli.tui.worker.CoderWorker object at 0x000001F2BE3842F0\u003e │ │\n│ 189 │ │ │ pass ╰────────────────────────────────────────────────────────────────────╯ │\n│ ❱ 190 │ │ self.interrupt() │\n│ │\n│ 191 │ │\n│ 192 │ # Wait for thread to finish │\n│ │\n│ 193 │ if self.thread and self.thread.is_alive(): │\n│ │\n│ C:\\Users\\PDitty\\AppData\\Roaming\\uv\\tools\\cecli-dev\\Lib\\site-packages\\cecli\\tui\\worker.py:160 in interrupt │\n│ │\n│ 157 │ │ if target_coder and hasattr(target_coder, \"io\") and target_coder.io: ╭────────────────────────────────────────── locals ──────────────────────────────────────────╮ │\n│ 158 │ │ # Cancel the output task if it exists agent_service = \u003ccecli.helpers.agents.service.AgentService object at 0x000001F2BF46DFD0\u003e │ │\n│ 159 │ │ if hasattr(target_coder.io, \"output_task\") and target_coder.io.output_task: │ foreground = \u003ccecli.coders.editblock_coder.EditBlockCoder object at 0x000001F30126C2D0\u003e │ │\n│ ❱ 160 │ │ │ target_coder.io.output_task.cancel() │ self = \u003ccecli.tui.worker.CoderWorker object at 0x000001F2BE3842F0\u003e │\n│ 161 │ │ │ # Also set output_running to False to stop the output_task loop │ target_coder = \u003ccecli.coders.editblock_coder.EditBlockCoder object at 0x000001F30126C2D0\u003e │ │\n│ 162 │ │ │ if hasattr(target_coder, \"output_running\"): ╰────────────────────────────────────────────────────────────────────────────────────────────╯ │\n│ 163 │ │ │ │ target_coder.output_running = False │\n│ │\n│ D:\\Python\\Python3_13_9\\Lib\\asyncio\\base_events.py:833 in call_soon │\n│ │\n│ 830 │ │ Any positional arguments after the callback will be passed to ╭──────────────────────────────────────── locals ────────────────────────────────────────╮ │\n│ 831 │ │ the callback when it is called. args = (\u003cFuture cancelled\u003e,) │\n│ 832 │ │ \"\"\" │\n│ 833 │ │ callback = \u003cbuilt-in method task_wakeup of _asyncio.Task object at 0x000001F3025E4F70\u003e │\n│ ❱ 833 │ │ self._check_closed() │\n│ 834 │ │ context = \u003c_contextvars.Context object at 0x000001F3019E3080\u003e │\n│ │\n│ 835 │ │ if self._debug: │\n│ 836 │ │ │ self._check_thread() │\n│ 837 │ │ self = \u003c_WindowsSelectorEventLoop running=False closed=True debug=False\u003e ╰───────────────────────────────────────────────────────────────────────────────────────────╯ │\n│ │\n│ 838 │ │ │ self._check_callback(callback, 'call_soon') │\n│ │\n│ D:\\Python\\Python3_13_9\\Lib\\asyncio\\base_events.py:556 in _check_closed │\n│ │\n│ 553 │ │ │\n│ 554 │ def _check_closed(self): │\n│ 555 │ │ if self._closed: │\n│ 556 │ │ │ raise RuntimeError('Event loop is closed') │\n```\n\n## Environment\n- **cecli version**: Latest (from cecli-dev)\n- **Python version**: 3.13.9\n- **OS**: Windows 11\n\n## Additional Context\nThe error occurs in the following call chain:\n1. `TUI._do_quit()` calls `self.worker.stop()`\n2. `CoderWorker.stop()` calls `self.interrupt()`\n3. `CoderWorker.interrupt()` attempts to cancel `target_coder.io.output_task`\n4. This triggers `asyncio.base_events.call_soon()` which calls `_check_closed()`\n5. The event loop is already closed, raising the `RuntimeError`\n\n## Expected Behavior\nThe TUI should quit gracefully without raising an exception.\n\n## Possible Fix\nThe issue appears to be a race condition where the event loop is closed before the output task is properly cancelled. A potential fix would be to check if the event loop is still running before attempting to cancel tasks.\n","author":{"url":"https://github.com/szmania","@type":"Person","name":"szmania"},"datePublished":"2026-06-05T19:52:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/558/cecli/issues/558"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b506cc22-bc9d-c66a-2eb5-68009bb831a2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 84A0:138E47:8AECFC:BE67E5:6A6129B0 |
| html-safe-nonce | bcb804adcc853c15af59d51f9b2e228df5ce7808f3f622b160eb43ab49160149 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NEEwOjEzOEU0Nzo4QUVDRkM6QkU2N0U1OjZBNjEyOUIwIiwidmlzaXRvcl9pZCI6Ijg4NDczMTY4NjEyNTQxODMzNDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2f97a1b8ce8541e226656c1150ced1ad1d63e3cbc2e187f454cf6f1292c6ed18 |
| hovercard-subject-tag | issue:4599706771 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/cecli-dev/cecli/558/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7864a16369b11bdcd3571a9b85cab9b0610effa3487a96032e88dafd586a0110/cecli-dev/cecli/issues/558 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7864a16369b11bdcd3571a9b85cab9b0610effa3487a96032e88dafd586a0110/cecli-dev/cecli/issues/558 |
| og:image:alt | Description When attempting to quit the cecli TUI, a RuntimeError: Event loop is closed is raised, causing the application to crash. Steps to Reproduce Start cecli TUI Attempt to quit (e.g., by pre... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | szmania |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6896275b704df9b9258326d49c8695aecd98d736cd9eeda7bcbb1790ac97d3ad |
| turbo-cache-control | no-preview |
| go-import | github.com/cecli-dev/cecli git https://github.com/cecli-dev/cecli.git |
| octolytics-dimension-user_id | 250452847 |
| octolytics-dimension-user_login | cecli-dev |
| octolytics-dimension-repository_id | 1030985330 |
| octolytics-dimension-repository_nwo | cecli-dev/cecli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | true |
| octolytics-dimension-repository_parent_id | 638629097 |
| octolytics-dimension-repository_parent_nwo | Aider-AI/aider |
| octolytics-dimension-repository_network_root_id | 638629097 |
| octolytics-dimension-repository_network_root_nwo | Aider-AI/aider |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | af89f6cd55841b57fa09b6b0ed9e3f8f2e94b05d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width