Skip to content

Commit

Permalink
fix(jobs): remove loop parameter from Semaphore in Python 3.8+ (#74)
Browse files Browse the repository at this point in the history
The `loop` paramater of the `Semaphore` constructor is deprecated since
Python 3.8 and removed in 3.10.
  • Loading branch information
HiPhish authored Oct 17, 2021
1 parent 7861d19 commit 71290da
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rplugin/python3/ultest/vim_client/jobs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def __init__(self, num_threads: int = 2):
self._jobs: defaultdict[str, Dict[str, Event]] = defaultdict(dict)
self._loop = asyncio.new_event_loop()
self._thread = Thread(target=self._loop.run_forever, daemon=True)
self._sem = Semaphore(num_threads, loop=self._loop)
self._thread.start()
if sys.version_info < (3, 8):
# Use the new default watcher from >= 3.8, implemented locally
Expand All @@ -27,6 +26,9 @@ def __init__(self, num_threads: int = 2):

logger.info("Using local threaded child watcher")
asyncio.set_child_watcher(ThreadedChildWatcher())
self._sem = Semaphore(num_threads, loop=self._loop)
else:
self._sem = Semaphore(num_threads)

@property
def semaphore(self) -> Semaphore:
Expand Down

0 comments on commit 71290da

Please sign in to comment.