Commit 2ea0b465 authored by Jason Madden's avatar Jason Madden

Make the check_callback do stuff under PyPy to trigger signal delivery. Fixes #1112.

parent a5f7a836
...@@ -82,6 +82,10 @@ ...@@ -82,6 +82,10 @@
- Fix a race condition in libuv child callbacks. See :issue:`1104`. - Fix a race condition in libuv child callbacks. See :issue:`1104`.
- Signal handling under PyPy with libuv is more reliable. See
:issue:`1112`.
1.3a1 (2018-01-27) 1.3a1 (2018-01-27)
================== ==================
......
...@@ -14,6 +14,7 @@ from gevent._ffi import GEVENT_DEBUG_LEVEL ...@@ -14,6 +14,7 @@ from gevent._ffi import GEVENT_DEBUG_LEVEL
from gevent._ffi import TRACE from gevent._ffi import TRACE
from gevent._ffi import CRITICAL from gevent._ffi import CRITICAL
from gevent._ffi.callback import callback from gevent._ffi.callback import callback
from gevent._compat import PYPY
from gevent import getswitchinterval from gevent import getswitchinterval
...@@ -225,7 +226,8 @@ class AbstractCallbacks(object): ...@@ -225,7 +226,8 @@ class AbstractCallbacks(object):
watcher = self.from_handle(handle) watcher = self.from_handle(handle)
watcher.stop() watcher.stop()
def python_check_callback(self, watcher_ptr): if not PYPY:
def python_check_callback(self, watcher_ptr): # pylint:disable=unused-argument
# If we have the onerror callback, this is a no-op; all the real # If we have the onerror callback, this is a no-op; all the real
# work to rethrow the exception is done by the onerror callback # work to rethrow the exception is done by the onerror callback
...@@ -233,6 +235,23 @@ class AbstractCallbacks(object): ...@@ -233,6 +235,23 @@ class AbstractCallbacks(object):
# to the C level structure, *not* a pointer to the void* that represents a # to the C level structure, *not* a pointer to the void* that represents a
# <cdata> for the Python Watcher object. # <cdata> for the Python Watcher object.
pass pass
else: # PyPy
# On PyPy, we need the function to have some sort of body, otherwise
# the signal exceptions don't always get caught, *especially* with
# libuv (however, there's no reason to expect this to only be a libuv
# issue; it's just that we don't depend on the periodic signal timer
# under libev, so the issue is much more pronounced under libuv)
# test_socket's test_sendall_interrupted can hang.
# See https://github.com/gevent/gevent/issues/1112
def python_check_callback(self, watcher_ptr): # pylint:disable=unused-argument
# Things we've tried that *don't* work:
# greenlet.getcurrent()
# 1 + 1
try:
raise MemoryError()
except MemoryError:
pass
def python_prepare_callback(self, watcher_ptr): def python_prepare_callback(self, watcher_ptr):
loop = self._find_loop_from_c_watcher(watcher_ptr) loop = self._find_loop_from_c_watcher(watcher_ptr)
......
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