interactions.py icon indicating copy to clipboard operation
interactions.py copied to clipboard

[BUG] Unexpected Bucket Already Locked Error

Open BigChungus888 opened this issue 1 year ago • 0 comments

Library Version

5.13.2

Describe the Bug

Currently unable to consistently report it and not sure the cause. It occurs sometimes and sometimes it works fine. Basically, I run fetch_user (without force=True) in an autocomplete function. Then I get bucket already locked at times.

Steps to Reproduce

  1. Create a command with autocomplete.
  2. Do fetch_user in the autocomplete function.

Expected Results

No error produced.

Minimal Reproducible Code

@base_info.autocomplete(option_name="base_link")
async def base_autocomplete(self, ctx: ipy.AutocompleteContext):
    for some_id in some_ids:
        await self.bot.fetch_user(some_id)
    return some_choices

Traceback

Traceback (most recent call last):
  File "/home/container/.local/lib/python3.11/site-packages/interactions/client/client.py", line 2018, in __dispatch_interaction
    response = await callback
               ^^^^^^^^^^^^^^
  File "/home/container/cogs/BaseCommands.py", line 205, in base_autocomplete
    builder = await self.bot.fetch_user(base_data["builder"]) if base_data["builder"] else "@anonymous"
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.11/site-packages/interactions/client/client.py", line 2366, in fetch_user
    return await self.cache.fetch_user(user_id, force=force)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.11/site-packages/interactions/client/smart_cache.py", line 120, in fetch_user
    data = await self._client.http.get_user(user_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.11/site-packages/interactions/api/http/http_requests/users.py", line 38, in get_user
    return await self.request(Route("GET", "/users/{user_id}", user_id=user_id))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/container/.local/lib/python3.11/site-packages/interactions/api/http/http_client.py", line 446, in request
    await lock.lock_for_duration(lock.delta, block=True)
  File "/home/container/.local/lib/python3.11/site-packages/interactions/api/http/http_client.py", line 188, in lock_for_duration
    raise RuntimeError("Attempted to lock a bucket that is already locked.")
RuntimeError: Attempted to lock a bucket that is already locked.

Checklist

  • [X] I have searched the open issues for duplicates.
  • [X] I have shown the entire traceback, if possible.
  • [X] I have removed my token from display, if visible.
  • [X] I have attempted to debug this myself, and I believe this issue is with the library

Additional Information

No response

BigChungus888 avatar Sep 11 '24 05:09 BigChungus888