Skip to content

Commit

Permalink
Max concurrency things in Command.prepare()
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackenmen committed Jan 13, 2021
1 parent 679c995 commit d91ff8f
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions redbot/core/commands/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,15 +485,22 @@ async def prepare(self, ctx):
if not await self.can_run(ctx, change_permission_state=True):
raise CheckFailure(f"The check functions for command {self.qualified_name} failed.")

if self.cooldown_after_parsing:
await self._parse_arguments(ctx)
self._prepare_cooldowns(ctx)
else:
self._prepare_cooldowns(ctx)
await self._parse_arguments(ctx)
if self._max_concurrency is not None:
await self._max_concurrency.acquire(ctx)
await self.call_before_hooks(ctx)

try:
if self.cooldown_after_parsing:
await self._parse_arguments(ctx)
self._prepare_cooldowns(ctx)
else:
self._prepare_cooldowns(ctx)
await self._parse_arguments(ctx)

await self.call_before_hooks(ctx)
except:
if self._max_concurrency is not None:
await self._max_concurrency.release(ctx)
raise

async def do_conversion(
self, ctx: "Context", converter, argument: str, param: inspect.Parameter
Expand Down

0 comments on commit d91ff8f

Please sign in to comment.