Commit c311d17b authored by Jason Madden's avatar Jason Madden

Get tests passing with libuv on Python 3.6

This requires some changes to the way we handle errors, specifically
for signals in the monkey-patched test_selectors.py and
test_socket.py.

It's not absolutely clear that this is the right thing to do in all
cases.
parent 48d8b1e9
......@@ -11,16 +11,17 @@ env:
# These are ordered to get as much diversity in the
# first group of parallel runs (4) as posible
- TASK=test-py27-libuv
#- TASK=test-py27-noembed
#- TASK=test-pypy
#- TASK=test-py36
- TASK=test-py36-libuv
- TASK=test-py27-noembed
- TASK=test-pypy
- TASK=test-py36
- TASK=lint-py27
#- TASK=test-pypy3
#- TASK=test-py35
#- TASK=test-py278
#- TASK=test-py27
#- TASK=test-py34
#- TASK=test-py27-cffi
- TASK=test-pypy3
- TASK=test-py35
- TASK=test-py278
- TASK=test-py27
- TASK=test-py34
- TASK=test-py27-cffi
matrix:
fast_finish: true
......
......@@ -185,6 +185,9 @@ test-py35: $(PY35)
test-py36: $(PY36)
PYTHON=python3.6.2 PIP=pip PATH=$(BUILD_RUNTIMES)/versions/python3.6.2/bin:$(PATH) make develop toxtest
test-py36-libuv: $(PY36)
GEVENT_CORE_CFFI_ONLY=libuv make test-py36
test-pypy: $(PYPY)
PYTHON=$(PYPY) PIP=pip PATH=$(BUILD_RUNTIMES)/versions/pypy580/bin:$(PATH) make develop toxtest
......@@ -195,7 +198,7 @@ test-py27-cffi: $(PY27)
GEVENT_CORE_CFFI_ONLY=1 PYTHON=python2.7.14 PATH=$(BUILD_RUNTIMES)/versions/python2.7.14/bin:$(PATH) make develop toxtest
test-py27-libuv: $(PY27)
GEVENT_CORE_CFFI_ONLY=libuv PYTHON=python2.7.14 PATH=$(BUILD_RUNTIMES)/versions/python2.7.14/bin:$(PATH) make develop toxtest
GEVENT_CORE_CFFI_ONLY=libuv make test-py27
test-py27-noembed: $(PY27)
cd deps/libev && ./configure --disable-dependency-tracking && make
......
......@@ -112,7 +112,17 @@ class _Callbacks(object):
watcher = self.ffi.from_handle(handle)
exc_info = watcher._exc_info
del watcher._exc_info
watcher.loop.handle_error(watcher, *exc_info)
# In the past, we passed the ``watcher`` itself as the context,
# which typically meant that the Hub would just print
# the exception. This is a problem because sometimes we can't
# detect signals until late in ``python_callback``; specifically,
# test_selectors.py:DefaultSelectorTest.test_select_interrupt_exc
# installs a SIGALRM handler that raises an exception. That exception can happen
# before we enter ``python_callback`` or at any point within it because of the way
# libuv swallows signals. By passing None, we get the exception prapagated into
# the main greenlet (which is probably *also* not what we always want, but
# I see no way to distinguish the cases).
watcher.loop.handle_error(None, *exc_info)
finally:
# XXX Since we're here on an error condition, and we
# made sure that the watcher object was put in loop._keepaliveset,
......@@ -126,6 +136,15 @@ class _Callbacks(object):
watcher.loop.handle_error(watcher, *sys.exc_info())
return # pylint:disable=lost-exception
def unhandled_onerror(self, t, v, tb):
# This is supposed to be called for signals, etc.
if tb is not None:
handle = tb.tb_frame.f_locals['handle']
watcher = self.ffi.from_handle(handle)
watcher.loop._check_callback_handle_error(t, v, tb)
else:
raise v
def python_stop(self, handle):
watcher = self.ffi.from_handle(handle)
watcher.stop()
......@@ -137,7 +156,7 @@ def assign_standard_callbacks(ffi, lib):
for sig, func in (("int(void* handle, int revents)", callbacks.python_callback),
("void(void* handle, int revents)", callbacks.python_handle_error),
("void(void* handle)", callbacks.python_stop)):
callback = ffi.callback(sig)(func)
callback = ffi.callback(sig, onerror=callbacks.unhandled_onerror)(func)
# keep alive the cdata
callbacks.callbacks.append(callback)
# pass to the library C variable
......
......@@ -306,7 +306,7 @@ class io(_base.IoMixin, watcher):
# the reader, we get a LoopExit. So we can't return here and arguably shouldn't print it
# either. The negative events mask will match the watcher's mask.
# See test__fileobject.py:Test.test_newlines for an example.
#return
# return
for watcher_ref in self._multiplex_watchers:
watcher = watcher_ref()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment