Skip to content

asyncio.TaskGroup AttributeError crashes background_task_loop β€” tasks stay STATUS_SCHEDULED forever, never picked upΒ #284

Description

@ogamingSCV

How to use GitHub

  • Please use the πŸ‘ reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

I am trying to get local LLM working with my Nextcloud install. After some initial hurtles I am now stuck here and can't really find any useful information.

Steps to reproduce

  1. Set up AppAPI with a HaRP deploy daemon on a remote/CPU-only host (separate machine from the Nextcloud host, connected via FRP tunnel).
  2. Install the "Local large language model" ExApp (llm2 version 2.8.0, image ghcr.io/nextcloud/llm2:2.8.0) on that remote daemon. Default shipped model gemma-4-E4B_q4_0-it.gguf is used, no custom model.
  3. Test AI Chat

Expected behaviour

Any response for the Assistant/LLM

Actual behaviour

  • POST /trigger?providerId=llm2%3Agemma-4-E4B_q4_0-it%3Acore%3Atext2text%3Achat is received by the container and answered with 200 OK every time.
  • The task on the Nextcloud side never progresses. startedAt remains null indefinitely, error_message is also null β€” no error is ever surfaced to the user or admin, the task simply stays STATUS_SCHEDULED forever.
  • Immediately at container/app startup (before any request), the following exception is logged and the internal background_task_loop crashes:
File "/app/lib/main.py", line 204, in _background_task_loop_inner
    async with asyncio.TaskGroup() as tg:
  AttributeError: module 'asyncio' has no attribute 'TaskGroup'

as well we:

connect to server error: dial tcp <HARP-IP>:8782: connect: connection refused

Server configuration

Web server: Nginx

Database: PostgreSQL

PHP version: 8.4

Nextcloud version: 34.0.1

ERROR:    Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/llm2-9TtSrW0h-py3.10/lib/python3.10/site-packages/starlette/routing.py", line 638, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "/usr/lib/python3.10/contextlib.py", line 206, in __aexit__
    await anext(self.gen)
  File "/app/lib/main.py", line 271, in lifespan
    await bg
  File "/app/lib/main.py", line 186, in background_task_loop
    await _background_task_loop_inner()
  File "/app/lib/main.py", line 204, in _background_task_loop_inner
    async with asyncio.TaskGroup() as tg:
AttributeError: module 'asyncio' has no attribute 'TaskGroup'
TRACE:    ASGI [1] Raised exception
ERROR:    Application shutdown failed. Exiting.
INFO:     Finished server process [1]
SIGTERM received. Finishing in-flight tasks before shutdown...
HP_SHARED_KEY is set, creating /frpc.toml configuration file...
Found /certs/frp directory. Creating configuration with TLS certificates.
Starting frpc in the background...
Starting application: poetry run python3 main.py
2026-07-28 13:09:32.490 [I] [sub/root.go:142] start frpc service for config file [/frpc.toml]
2026-07-28 13:09:32.491 [I] [client/service.go:295] try to connect to server...
2026-07-28 13:09:32.499 [W] [client/service.go:298] connect to server error: dial tcp <HARP-IP>:8782: connect: connection refused
2026-07-28 13:09:34.692 [I] [client/service.go:295] try to connect to server...
2026-07-28 13:09:34.712 [I] [client/service.go:287] [1f75827a06a83b67] login to server success, get run id [1f75827a06a83b67]
2026-07-28 13:09:34.712 [I] [proxy/proxy_manager.go:173] [1f75827a06a83b67] proxy added: [llm2]
2026-07-28 13:09:34.720 [I] [client/control.go:168] [1f75827a06a83b67] [llm2] start proxy success
INFO:     Started server process [1]
INFO:     Waiting for application startup.
TRACE:    ASGI [1] Started scope={'type': 'lifespan', 'asgi': {'version': '3.0', 'spec_version': '2.0'}, 'state': {}}
TRACE:    ASGI [1] Receive {'type': 'lifespan.startup'}
TRACE:    ASGI [1] Send {'type': 'lifespan.startup.complete'}
2026-07-28 13:09:36,779 - main - ERROR - background_task_loop crashed
Traceback (most recent call last):
  File "/app/lib/main.py", line 186, in background_task_loop
    await _background_task_loop_inner()
  File "/app/lib/main.py", line 204, in _background_task_loop_inner
    async with asyncio.TaskGroup() as tg:
AttributeError: module 'asyncio' has no attribute 'TaskGroup'
INFO:     Application startup complete.
INFO:     Uvicorn running on unix socket /tmp/exapp.sock (Press CTRL+C to quit)
TRACE:    HTTP connection made
TRACE:    ASGI [2] Started scope={'type': 'http', ... 'method': 'POST', 'path': '/trigger', 'query_string': b'providerId=llm2%3Agemma-4-E4B_q4_0-it%3Acore%3Atext2text%3Achat'}
TRACE:    ASGI [2] Send {'type': 'http.response.start', 'status': 200, 'headers': '<...>'}
INFO:      - "POST /trigger?providerId=llm2%3Agemma-4-E4B_q4_0-it%3Acore%3Atext2text%3Achat HTTP/1.1" 200 OK
TRACE:    ASGI [2] Send {'type': 'http.response.body', 'body': '<2 bytes>'}
TRACE:    ASGI [2] Completed
TRACE:    HTTP connection lost
$ sudo -u www-data php /var/www/nextcloud/occ taskprocessing:task:get --output=json_pretty 30
{
    "id": 30,
    "type": "core:text2text:chat",
    "lastUpdated": 1785245532,
    "status": "STATUS_SCHEDULED",
    "userId": "dwm",
    "appId": "assistant:chatty-llm",
    "input": {
        "system_prompt": "...",
        "input": "test",
        "history": [],
        "memories": []
    },
    "output": null,
    "customId": "chatty-llm:11",
    "completionExpectedAt": 1785245562,
    "progress": 0,
    "scheduledAt": 1785245532,
    "startedAt": null,
    "endedAt": null,
    "allowCleanup": true,
    "includeWatermark": true,
    "userFacingErrorMessage": null,
    "error_message": null
}

$ sudo -u www-data php /var/www/nextcloud/occ taskprocessing:task:get --output=json_pretty 31
{
    "id": 31,
    "type": "core:text2text:chat",
    "lastUpdated": 1785245604,
    "status": "STATUS_SCHEDULED",
    "userId": "dwm",
    "appId": "assistant:chatty-llm",
    "input": {
        "system_prompt": "...",
        "input": "todays news",
        "history": [],
        "memories": []
    },
    "output": null,
    "customId": "chatty-llm:12",
    "completionExpectedAt": 1785245634,
    "progress": 0,
    "scheduledAt": 1785245604,
    "startedAt": null,
    "endedAt": null,
    "allowCleanup": true,
    "includeWatermark": true,
    "userFacingErrorMessage": null,
    "error_message": null
}

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions