Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Address shutdown behavior#6633

Open
NNTin wants to merge 4 commits intoCog-Creators:V3/developfrom
NNTin:fix/dry-run
Open

Address shutdown behavior#6633
NNTin wants to merge 4 commits intoCog-Creators:V3/developfrom
NNTin:fix/dry-run

Conversation

@NNTin
Copy link
Contributor

Analysis of the problem

Problem Analysis

Based on the error traceback and codebase investigation, here's what's happening:

The Error

AttributeError: 'Red' object has no attribute '_AutoShardedClient__queue'. Did you mean: '_AutoShardedClient__shards'?

This error occurs during the bot shutdown process when red.close() is called. The issue is that the Red class (which inherits from discord.ext.commands.AutoShardedBot) is trying to access an internal attribute __queue that doesn't exist.

Root Cause

The problem stems from themixin initialization order in the Red class:

classRed(commands.GroupMixin,RPCMixin,dpy_commands.bot.AutoShardedBot):

Looking at the initialization chain:

  1. Red.init (line 104-241 in bot.py) does extensive setup work BEFORE calling super().init() at line 241

  2. RPCMixin.init (line 144-146 in _rpc.py) calls super().init(**kwargs)

  3. commands.GroupMixin doesn't defineinit, so it passes through

  4. Finally reachesAutoShardedBot.init which sets up internal attributes like __queue

The issue is that during the --dry-run execution:

  • The bot starts initialization

  • At line 366 inmain.py, when --dry-run is detected, it calls sys.exit(ExitCodes.SHUTDOWN)

  • This triggers the shutdown handler at line 539

  • The shutdown handler calls await red.close() at line 441

  • But red.close() → super().close() (line 2278 in bot.py) tries to access AutoShardedClient's internal __queue attribute

  • This attribute was never properly initialized because the initialization was interrupted

Why This Happens Specifically with --dry-run

The --dry-run flag causes an early exit at line 365-366 inmain.py:

ifcli_flags.dry_run:sys.exit(ExitCodes.SHUTDOWN)

This happensbefore await red.start(token) is called (line 369), which means:

  • The bot's connection lifecycle never begins

  • Discord.py's internal sharding infrastructure (including __queue) is never fully initialized

  • But the shutdown handler still tries to call close() which expects these internals to exist

try, catch might not be the best solution but I can't think of a better one. This only happens when it is not fully initialized and thus sharding is not possible.

closes#6572
the original issue is also addressed.

PS C:\privat\codex\Red-DiscordBot> python-m redbot--no-promptError: No instance name was provided!PS C:\privat\codex\Red-DiscordBot> python-m redbot--no-prompt tinkererInstance with name'tinkerer' doesn't exist. You can create new instance using `redbot-setup` prior to running the bot.

@github-actionsgithub-actionsbot added the Category: Core - Bot ClassThis is related to the `redbot.core.bot.Red` class. labelNov 21, 2025
@github-actionsgithub-actionsbot added the Category: MetaThis is related to the repository maintenance. labelNov 21, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

Category: Core - Bot ClassThis is related to the `redbot.core.bot.Red` class.Category: MetaThis is related to the repository maintenance.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Starting a bot with missing configuration may exit with code 1 instead of expected 78

1 participant

@NNTin

[8]ページ先頭

©2009-2026 Movatter.jp