Skip to content

Commit

Permalink
Add bucket attribute to MaxConcurrencyLimitReached (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonxslays committed Apr 17, 2023
1 parent 6998736 commit 91477b0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
7 changes: 7 additions & 0 deletions docs/source/changelogs/v2-changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ Below are all the changelogs for the stable versions of hikari-lightbulb (versio

----

Version 2.3.3
=============

**Other Changes**

- ``bucket`` attribute has been added to the :obj:`~lightbulb.errors.MaxConcurrencyLimitReached` class.

Version 2.3.2
=============

Expand Down
3 changes: 2 additions & 1 deletion lightbulb/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,8 @@ async def _evaluate_max_concurrency(self, context: context_.base.Context) -> Non
if self._max_concurrency_semaphores[bucket_hash].locked():
assert context.invoked is not None
raise errors.MaxConcurrencyLimitReached(
f"Maximum concurrency limit for command '{context.invoked.qualname}' exceeded"
f"Maximum concurrency limit for command '{context.invoked.qualname}' exceeded",
bucket=self.max_concurrency[1],
)
await self._max_concurrency_semaphores[bucket_hash].acquire()

Expand Down
14 changes: 13 additions & 1 deletion lightbulb/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import hikari

if t.TYPE_CHECKING:
from lightbulb import buckets
from lightbulb import commands


Expand Down Expand Up @@ -160,7 +161,7 @@ def __init__(self, *args: t.Any, opt: commands.base.OptionLike, raw: str) -> Non
self.raw_value: str = raw
"""
The value that could not be converted.
.. versionadded:: 2.2.1
"""

Expand Down Expand Up @@ -197,6 +198,17 @@ class MaxConcurrencyLimitReached(LightbulbError):
has been exceeded.
"""

__slots__ = ("bucket",)

def __init__(self, *args: t.Any, bucket: t.Type[buckets.Bucket]) -> None:
super().__init__(*args)
self.bucket = bucket
"""
The bucket type that triggered the max concurrency limit.
.. versionadded:: 2.3.3
"""


class CheckFailure(LightbulbError):
"""
Expand Down

0 comments on commit 91477b0

Please sign in to comment.