Skip to content

Commit 71290da

Browse files
authored
fix(jobs): remove loop parameter from Semaphore in Python 3.8+ (#74)
The `loop` paramater of the `Semaphore` constructor is deprecated since Python 3.8 and removed in 3.10.
1 parent 7861d19 commit 71290da

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

rplugin/python3/ultest/vim_client/jobs/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ def __init__(self, num_threads: int = 2):
1818
self._jobs: defaultdict[str, Dict[str, Event]] = defaultdict(dict)
1919
self._loop = asyncio.new_event_loop()
2020
self._thread = Thread(target=self._loop.run_forever, daemon=True)
21-
self._sem = Semaphore(num_threads, loop=self._loop)
2221
self._thread.start()
2322
if sys.version_info < (3, 8):
2423
# Use the new default watcher from >= 3.8, implemented locally
@@ -27,6 +26,9 @@ def __init__(self, num_threads: int = 2):
2726

2827
logger.info("Using local threaded child watcher")
2928
asyncio.set_child_watcher(ThreadedChildWatcher())
29+
self._sem = Semaphore(num_threads, loop=self._loop)
30+
else:
31+
self._sem = Semaphore(num_threads)
3032

3133
@property
3234
def semaphore(self) -> Semaphore:

0 commit comments

Comments
 (0)