Discord worker cannot start on Python 3.13: build_bot() raises "no current event loop" #248
Labels
No labels
burndown-2026-06
headless
autonomy
async-consult
autonomy
epic
autonomy
headless
autonomy
live-collab
c#
priority
P0
priority
P1
priority
P2
priority
P3
priority
P4
role/ai
role/creator
role/design
role/director
role/engineer
role/exec
role/human
role/ops
role/qa
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
coilyco-gaming/eco-app#248
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
ward exec testhas one failing test onmain:It is not a test-only problem. The same call path runs in production.
Mechanism
build_bot()constructsdiscord.Bot(...)synchronously, beforebot.run(). Pycord reads the ambient loop during construction, and its compatibility guard only covers Python 3.14 and up —discord/utils.py:On Python 3.13 a bare
asyncio.get_event_loop()raises when no loop is running and none has been set. This repo targets 3.13 (target-version = "py313",python_version = "3.13"), soworker.main()raises atbuild_bot()before it ever reachesbot.run().The two sibling tests pass only because they assert on
RuntimeErrorraised by the env-var validation, which happens before thediscord.Bot(...)call.Versions: py-cord 2.8.0, pinned
>=2.6.1,<3.0.0.Fix
Ensure a current event loop exists before constructing the Bot — the same thing pycord does for itself on 3.14. Do nothing when a loop is already running or already set.
Acceptance
ward exec testis green, with no pre-existing failure to explain away.build_bot()is covered by a test that constructs the Bot outside a running loop, which is howmain()calls it.main()still runs the bot on the loop that gets created.Origin
Noticed as the standing red test while working the 2026-08-12 QA sweep (#240). It predates that work — it is on
mainindependently.