Skip to content

Async Lock not being acquired #616

@Jakan-Kink

Description

@Jakan-Kink

Describe the bug

When getting a 429 or other request for slowdown the script tries to fire managers/sessionmanager/sessionmanager.py line 122 async with self._alock: direct source link except that lock is bound to a different event loop

To Reproduce

Normal heavy load that triggers a 429 or other slowdown

Expected behavior

The lock to be grabbed and thus the script pauses for a few seconds for the 429 to quite

Screenshots/Logs

 2026-03-31 12:26:18:[level.inner:10]  Traceback (most recent call last):
  File "/app/.venv/lib/python3.13/site-packages/{home_directory}/data/api/labels.py", line 272, in scrape_posts_labels
    async with c.requests_async(url) as r:
               ~~~~~~~~~~~~~~~~^^^^^
  File "/usr/local/lib/python3.13/contextlib.py", line 214, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.13/site-packages/{home_directory}/managers/sessionmanager/ofsession.py", line 113, in requests_async
    async with super().requests_async(*args, **kwargs) as r:
               ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/contextlib.py", line 214, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.13/site-packages/{home_directory}/managers/sessionmanager/sessionmanager.py", line 614, in requests_async
    async for _ in AsyncRetrying(
    ...<62 lines>...
                raise E
  File "/app/.venv/lib/python3.13/site-packages/tenacity/_asyncio.py", line 71, in __anext__
    do = self.iter(retry_state=self._retry_state)
  File "/app/.venv/lib/python3.13/site-packages/tenacity/__init__.py", line 325, in iter
    raise retry_exc.reraise()
          ~~~~~~~~~~~~~~~~~^^
  File "/app/.venv/lib/python3.13/site-packages/tenacity/__init__.py", line 158, in reraise
    raise self.last_attempt.result()
          ~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/app/.venv/lib/python3.13/site-packages/{home_directory}/managers/sessionmanager/sessionmanager.py", line 677, in requests_async
    raise E
  File "/app/.venv/lib/python3.13/site-packages/{home_directory}/managers/sessionmanager/sessionmanager.py", line 628, in requests_async
    if await self._rate_limit_sleeper.async_do_sleep():
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/.venv/lib/python3.13/site-packages/{home_directory}/managers/sessionmanager/sessionmanager.py", line 122, in async_do_sleep
    async with self._alock:
               ^^^^^^^^^^^
  File "/usr/local/lib/python3.13/asyncio/locks.py", line 14, in __aenter__
    await self.acquire()
  File "/usr/local/lib/python3.13/asyncio/locks.py", line 105, in acquire
    fut = self._get_loop().create_future()
          ~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/asyncio/mixins.py", line 20, in _get_loop
    raise RuntimeError(f'{self!r} is bound to a different event loop')
RuntimeError: <asyncio.locks.Lock object at 0xe69f34cdb390 > is bound to a different event loop

Config

doesn't depend on config file, so not providing

System Info

Alpine Linux 3.22 ( docker image python:3.13-alpine ) with ffmpeg 7 from the 3.21 community.

Additional context

The custom docker is for smaller size and for using my:

  • after_action_script
  • post_script
  • after_download_script

and having their bundles included in the image.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions