aio-libs/janus

python 3.8 support without warnings

mpavlase opened this issue · 3 comments

Hi, I'm using janus 0.4.0 (from pypi) in python 3.8 and it generates this warning:

venv\lib\site-packages\janus\__init__.py:39: DeprecationWarning: The loop argument is deprecated since Python 3.8, and scheduled for removal in Python 3.10.

It's related to these lines:

janus/janus/__init__.py

Lines 40 to 45 in 32d16df

self._async_mutex = asyncio.Lock(loop=self._loop)
self._async_not_empty = asyncio.Condition(
self._async_mutex, loop=self._loop)
self._async_not_full = asyncio.Condition(
self._async_mutex, loop=self._loop)
self._finished = asyncio.Event(loop=self._loop)

In Python's standard library, asyncio.Queue also has the same issue and is going to be fixed.
I think janus should also follow the behavior of the standard asyncio: we need an explicit check that ensures janus.Queue instances are created with a currently running event loop.

Pull Request is welcome!

Hm... Fixing the code itself is not a big task, but I realized that the entire janus test suite is built upon the assumption where loop arguments must be passed around explicitly.

It is possible to rewrite the test cases, but I'm not sure that if removing explicit loop arguments completely would match with the intention of using janus queues.
Since janus is to bridge between sync and async worlds, its initialization may be done outside event loops with explicit loop references. Previously this was the case.

If we patch this issue, we need to explicitly state that the janus queues must be always created in the async world only.

Is this an acceptable semantic change for this project?