Skip to content

Backend bot client fails on Docker startup: Future attached to a different loop #5

Description

@akang943578

Summary

When running the official Docker Compose stack (Python 3.11, uvicorn), the backend fails during Telegram bot client startup with an asyncio event-loop error.

Environment

  • Official docker compose setup from this repository
  • Python 3.11
  • Uvicorn ASGI server
  • Failure location: backend/app/telegram.py around start_one_client (reported ~line 51)

Steps to reproduce

  1. Clone the repo and start services with the official Docker Compose configuration.
  2. Start the backend (uvicorn) as defined in the compose file.
  3. Observe startup logs during Telegram client initialization.

Expected behavior

All configured Telegram bot clients start successfully inside the running application process.

Actual behavior

  • Client 0 fails to start during start_one_client.
  • Error indicates a Future attached to a different loop (asyncio event loop mismatch).

Additional notes

  • Calling Telegram getMe separately with asyncio.run(...) works outside the uvicorn/Docker startup path.
  • Suggests the Pyrogram/Telegram client asyncio tasks may be bound to a different loop than the one uvicorn uses when the app starts bot clients on startup.

Error context (paraphrased)

Client 0 failed to start
Future attached to a different loop

(at telegram.pystart_one_client)

If maintainers need full stack traces or compose logs from a specific commit, I can attach them on request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions