Skip to content

Commit 27c36af

Browse files
committed
On python3.4+, only support asyncio and expose it to rplugins
Dissallow python3.3 python2.7 is unchanged (pyuv is still preferred; loop not exposed)
1 parent 80428b1 commit 27c36af

File tree

8 files changed

+33
-23
lines changed

8 files changed

+33
-23
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ python:
1616
# If the build matrix gets bigger, also update the number of runs
1717
# at the bottom of .scrutinizer.yml.
1818
- 2.7
19-
- 3.3
2019
- 3.4
2120
- 3.5
2221
- 3.6

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ connecting to and scripting Nvim processes through its msgpack-rpc API.
99

1010
#### Installation
1111

12-
Supports python 2.7, and 3.3 or later.
12+
Supports python 2.7, and 3.4 or later.
1313

1414
```sh
1515
pip2 install neovim

neovim/api/nvim.py

+4
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ def __init__(self, session, channel_id, metadata, types,
9090
self._decode = decode
9191
self._err_cb = err_cb
9292

93+
# only on python3.4+ we expose asyncio
94+
if IS_PYTHON3:
95+
self.loop = self._session.loop._loop
96+
9397
def _from_nvim(self, obj, decode=None):
9498
if decode is None:
9599
decode = self._decode

neovim/msgpack_rpc/async_session.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def __init__(self, msgpack_stream):
2727
1: self._on_response,
2828
2: self._on_notification
2929
}
30+
self.loop = msgpack_stream.loop
3031

3132
def threadsafe_call(self, fn):
3233
"""Wrapper around `MsgpackStream.threadsafe_call`."""

neovim/msgpack_rpc/event_loop/__init__.py

+15-7
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@
22
33
Tries to use pyuv as a backend, falling back to the asyncio implementation.
44
"""
5-
try:
6-
# libuv is fully implemented in C, use it when available
7-
from .uv import UvEventLoop
8-
EventLoop = UvEventLoop
9-
except ImportError:
10-
# asyncio(trollius on python 2) is pure python and should be more portable
11-
# across python implementations
5+
6+
from ...compat import IS_PYTHON3
7+
8+
# on python3 we only support asyncio, as we want to expose it to plugins
9+
if IS_PYTHON3:
1210
from .asyncio import AsyncioEventLoop
1311
EventLoop = AsyncioEventLoop
12+
else:
13+
try:
14+
# libuv is fully implemented in C, use it when available
15+
from .uv import UvEventLoop
16+
EventLoop = UvEventLoop
17+
except ImportError:
18+
# asyncio(trollius on python 2) is pure python and should be more portable
19+
# across python implementations
20+
from .asyncio import AsyncioEventLoop
21+
EventLoop = AsyncioEventLoop
1422

1523

1624
__all__ = ('EventLoop')

neovim/msgpack_rpc/msgpack_stream.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,19 @@ class MsgpackStream(object):
1919

2020
def __init__(self, event_loop):
2121
"""Wrap `event_loop` on a msgpack-aware interface."""
22-
self._event_loop = event_loop
22+
self.loop = event_loop
2323
self._packer = Packer(unicode_errors=unicode_errors_default)
2424
self._unpacker = Unpacker()
2525
self._message_cb = None
2626

2727
def threadsafe_call(self, fn):
2828
"""Wrapper around `BaseEventLoop.threadsafe_call`."""
29-
self._event_loop.threadsafe_call(fn)
29+
self.loop .threadsafe_call(fn)
3030

3131
def send(self, msg):
3232
"""Queue `msg` for sending to Nvim."""
3333
debug('sent %s', msg)
34-
self._event_loop.send(self._packer.pack(msg))
34+
self.loop .send(self._packer.pack(msg))
3535

3636
def run(self, message_cb):
3737
"""Run the event loop to receive messages from Nvim.
@@ -40,12 +40,12 @@ def run(self, message_cb):
4040
a message has been successfully parsed from the input stream.
4141
"""
4242
self._message_cb = message_cb
43-
self._event_loop.run(self._on_data)
43+
self.loop .run(self._on_data)
4444
self._message_cb = None
4545

4646
def stop(self):
4747
"""Stop the event loop."""
48-
self._event_loop.stop()
48+
self.loop .stop()
4949

5050
def _on_data(self, data):
5151
self._unpacker.feed(data)

neovim/msgpack_rpc/session.py

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def __init__(self, async_session):
2626
self._pending_messages = deque()
2727
self._is_running = False
2828
self._setup_exception = None
29+
self.loop = async_session.loop
2930

3031
def threadsafe_call(self, fn, *args, **kwargs):
3132
"""Wrapper around `AsyncSession.threadsafe_call`."""

setup.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77
install_requires = [
88
'msgpack>=0.5.0',
99
]
10-
extras_require = {
11-
'pyuv': ['pyuv>=1.0.0'],
12-
}
1310

14-
if os.name == 'nt':
15-
install_requires.append('pyuv>=1.0.0')
16-
elif sys.version_info < (3, 4):
17-
# trollius is just a backport of 3.4 asyncio module
18-
install_requires.append('trollius')
11+
if sys.version_info < (3, 4):
12+
if os.name == 'nt':
13+
install_requires.append('pyuv>=1.0.0')
14+
else:
15+
# trollius is just a backport of 3.4 asyncio module
16+
install_requires.append('trollius')
1917

2018
if platform.python_implementation() != 'PyPy':
2119
# pypy already includes an implementation of the greenlet module
@@ -32,5 +30,4 @@
3230
packages=['neovim', 'neovim.api', 'neovim.msgpack_rpc',
3331
'neovim.msgpack_rpc.event_loop', 'neovim.plugin'],
3432
install_requires=install_requires,
35-
extras_require=extras_require,
3633
zip_safe=False)

0 commit comments

Comments
 (0)