Skip to content

Commit

Permalink
Fix compatibility with Python 3.10, refs #358 (#359)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
  • Loading branch information
simonw and asvetlov committed Oct 24, 2021
1 parent 05d63e1 commit a6227af
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Expand Up @@ -43,7 +43,7 @@ jobs:
needs: lint
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
os: [ubuntu]
fail-fast:
false
Expand Down
4 changes: 4 additions & 0 deletions janus/__init__.py
@@ -1,4 +1,5 @@
import asyncio
import sys
import threading
from asyncio import QueueEmpty as AsyncQueueEmpty
from asyncio import QueueFull as AsyncQueueFull
Expand Down Expand Up @@ -36,6 +37,9 @@ def __init__(self, maxsize: int = 0) -> None:
self._all_tasks_done = threading.Condition(self._sync_mutex)

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)
self._finished = asyncio.Event()
Expand Down

0 comments on commit a6227af

Please sign in to comment.