Skip to content
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

Signal Handlers not Run While Client Iterates over Server-Streaming or Bidi RPC #19464

Closed
gnossen opened this issue Jun 25, 2019 · 3 comments
Closed

Comments

@gnossen
Copy link
Contributor

gnossen commented Jun 25, 2019

stub = foo_pb2_grpc.FooStub(channel)
result_generator = stub.StreamingRPC(foo_pb2.FooReques())

def cancel_request(unused_signum, unused_frame):
    result_generator.cancel()

signal.signal(signal.SIGINT, cancel_request)
for result in result_generator:
    do_stuff(result)

At the moment, iterating over result_generator can block the main thread indefinitely, not allowing the signal handler to run.

After discussing with @lidizheng , we believe that the main thread is caught up performing a blocking operation in Core, probably waiting on a completion queue. The thread should be yielded periodically so that signal handlers may be run.

@lidizheng
Copy link
Contributor

I presume we need to gdb the un-responsive process.

My guess about the completion queue block could be wrong since we already set 200 ms timeout for each wait, and checking signal in Cython explicitly. The blocking I think should be caused by other function call.

@lidizheng
Copy link
Contributor

As discussed offline, we are doing the periodical check in #19481. As suggested by @gnossen , the infinite timeout solution isn't ideal since it depends on CPython's implementation. However, if we perform the spin check in Python layer, we could have more control.

Related Python bug: https://bugs.python.org/issue35935.

@gnossen
Copy link
Contributor Author

gnossen commented Oct 14, 2019

Fixed by #19481

@lock lock bot locked as resolved and limited conversation to collaborators Jan 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants