Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

[Error] loop argument must agree with lock #1204

Closed
1 task done
systemime opened this issue Nov 12, 2021 · 2 comments
Closed
1 task done

[Error] loop argument must agree with lock #1204

systemime opened this issue Nov 12, 2021 · 2 comments
Labels

Comments

@systemime
Copy link

Describe the bug

loop argument must agree with lock

To Reproduce

I push websockeet in django project, but occasionally there is a problem of' loop argument must agree with lock.

In another project, I found a similar problem: aio-libs/janus#358

Expected behavior

No exception

Logs/tracebacks

aioredis/pool.py in __init__ at line 95
        self._cond = asyncio.Condition(lock=Lock())

asyncio/locks.py in __init__ at line 234
        def __init__(self, lock=None, *, loop=mixins._marker):
                super().__init__(loop=loop)
                if lock is None:
                    lock = Lock()
                elif lock._loop is not self._get_loop():
                 > raise ValueError("loop argument must agree with lock")


### Python Version

```console
$ python --version

3.10

aioredis Version

$ python -m pip show aioredis

1.3.1

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct
@systemime systemime added the bug label Nov 12, 2021
@asvetlov
Copy link
Contributor

CPython 3.10.0 has a bug regarding the usage of asyncio Condition with explicit lock.

It is fixed on the main branch and will be published as a part of 3.10.1 release.

Right now there is a workaround, like used in janus project:

       self._async_mutex = asyncio.Lock()
        if sys.version_info[:3] == (3, 10, 0):
            # Workaround for Python 3.10 bug, see #358:
            getattr(self._async_mutex, '_get_loop', lambda: None)()
        self._async_not_empty = asyncio.Condition(self._async_mutex)
        self._async_not_full = asyncio.Condition(self._async_mutex)

@systemime
Copy link
Author

CPython 3.10.0 has a bug regarding the usage of asyncio Condition with explicit lock.

It is fixed on the main branch and will be published as a part of 3.10.1 release.

Right now there is a workaround, like used in janus project:

       self._async_mutex = asyncio.Lock()
        if sys.version_info[:3] == (3, 10, 0):
            # Workaround for Python 3.10 bug, see #358:
            getattr(self._async_mutex, '_get_loop', lambda: None)()
        self._async_not_empty = asyncio.Condition(self._async_mutex)
        self._async_not_full = asyncio.Condition(self._async_mutex)

Thanks for the explanation, I will close this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants