New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyPy: test_socket test_sendall_interrupted sometimes hangs under libuv #1112

Closed
jamadden opened this Issue Feb 20, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@jamadden
Member

jamadden commented Feb 20, 2018

See https://travis-ci.org/gevent/gevent/jobs/343901539#L1312

The call to sendall blocks forever, waiting for the write event to become possible (which doesn't happen since there's no reader). That's supposed to be interrupted by an exception raised from a SIGALRM handler.

Debugging shows that what's happening is the SIGALRM signal is not getting delivered or handled by CFFI. Our interval timer is ticking, calling Callbacks.python_check_callback, and that's supposed to notice the signal and then call the check_callback_onerror to schedule delivery of the signal to the main greenlet. But that never happens.

If I make python_prepare_callback print something, (something more than a newline), e.g., print("."), everything works as expected.

This looks like a CFFI bug to me.

One workaround is to make gevent.signal handle SIGALRM in the same way that it handles SIGCHLD, using a signal watcher. I've tested that and it works to fix this test. An issue with that is that other signals would suffer from the same problem, so we'd ultimately need to do the same thing for all signals. I do like the idea of directing signals through signal watchers, especially under libuv, where signal handling is slow otherwise, but I'm reluctant to introduce that change due to compatibility concerns.

Perhaps another option is to introduce some more non-trivial code into the python_check_callback that reliably triggers the CFFI signal error handling.

@jamadden

This comment has been minimized.

Member

jamadden commented Feb 20, 2018

Raising and catching an exception in the body of python_check_callback seems to solve the issue.

jamadden added a commit that referenced this issue Feb 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment