-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
grpc client does not respect SIGINT when it can't connect to the server #4148
Comments
I get a similar error in Ruby.
|
@ctiller Could this be a core issue? |
Core does no signal handling nor masking AFAIK. It's most certainly a On Mon, Dec 7, 2015, 6:40 PM Masood Malekghassemi notifications@github.com
|
I mean the behavior wherein it's not timing out. |
I'm not aware of such. That doesn't mean no of course :) Getting a log with the environment variable GRPC_TRACE=api set would help pin point this. |
GRPC_TRACE=api doesn't seem to produce any more context around the above errors - I'm not sure which 'not timing out' issue is being referenced but I see timeouts and the client still doesn't exit, nor is any more information output as a trace:
And:
|
Can you post the log lines around grpc_channel_create_call? On Wed, Dec 9, 2015, 5:29 AM Glenn Matthews notifications@github.com
|
|
Masood: I1209 08:36:57.281937570 30150 channel.c:226] The timeout problem seems to be somewhere in the Python layer also (I see On Wed, Dec 9, 2015, 5:58 AM Glenn Matthews notifications@github.com
|
Ew. @glennmatthews what exactly was the code that you ran? (I ask because previous code in this thread sets the timeout to ten seconds and I want to know what you did and whether or not something else may be broken) |
@ctiller Oh, but, yes, the SIGINT thing is definitely a language runtime thing that should be addressed. I'm meandering a bit off-topic here because I'd have at least expected the SIGINT to work after a timeout. |
@update_metadata = proc do |md|
md[:username] = username
md[:password] = password
md
end
@exec = GRPCExec::Stub.new(address,
update_metadata: @update_metadata)
@timeout = nil ... response = stub.send(type, args, timeout: @timeout) If I set timeout to a numeric value, it does time out and fail on its own, raising a GRPC::BadStatus with DEADLINE_EXCEEDED status code, which appears to be correct. If I have a timeout number, but Ctrl-C during the failure, here's the log:
|
Yes, this is a problem, looks like timeout is not working... I don't want my function can't return and always wait for something. If my service is down... my clients may crazy! For now, I found a simple way to ignore this problem. but I don't know why, I did not look into the code. And this is a really bad code. But it's working. In python just add a try, except and do nothing: def run():
try:
channel = implementations.insecure_channel('localhost', 50051)
stub = addressbook_pb2.beta_create_PersonService_stub(channel)
response = stub.CallPerson(addressbook_pb2.PersonRequest(name='GUOJING'), _TIMEOUT_SECONDS)
print "Client received: " + response.reply
except:
pass Hope somebody found the reason of this problem. Or grpc is designed for the service which never down? |
thanks @GuoJing. However odd, your solution works for me! |
@GuoJing We handle services that are down; the SIGINT issue is a client-side problem above the layers in which communication occurs. Which version are you using? Do you still have the problem when using context management? def run():
channel = implementations.insecure_channel('localhost', 50051)
with addressbook_pb2.beta_create_PersonService_stub(channel) as stub:
response = stub.CallPerson(addressbook_pb2.PersonRequest(name='GUOJING'), _TIMEOUT_SECONDS)
print "Client received: " + response.reply |
@soltanmm sorry, I delete the comment. You solution is not working, is still get stuck. Ctrl + C. This is my code: from grpc.beta import implementations
import addressbook_pb2
_TIMEOUT_SECONDS = 1
def run():
channel = implementations.insecure_channel('localhost', 50051)
with addressbook_pb2.beta_create_PersonService_stub(channel) as stub:
response = stub.CallPerson(addressbook_pb2.PersonRequest(name='GUOJING'), _TIMEOUT_SECONDS)
print "Greeter client received: " + response.reply
if __name__ == '__main__':
run() |
@GuoJing Well, at least that slims down where the problem could be. Will look into it. |
We've talked about this with @murgatroid99, and this is a simple fix for the ruby code, that he'll implement. Perhaps he can work with @soltanmm or @nathanielmanistaatgoogle to do the same for python. |
@soltanmm @nathanielmanistaatgoogle @nicolasnoble - any updates on the python side? |
This specific failure, clients locking up/not responding when they are unable to connect to a server should be fixed for all C-based languages, including the 3 tagged here, by the fail-fast default introduced in the latest release. I am going to close this issue for now, and I think we should open up other issues if there are other situations where the library makes a program unresponsive. |
One such other issue already open is issue 3820 (Python). |
I'm still getting the same problem with v0.14.1. My code is essentially identical to @GuoJing's (also python) and am getting stuck in when the client becomes unresponsive in exactly the same way. Any idea when you'll have a fix?
|
@ninagittle: we hope to release 0.15 in the next few days; the problem should already be fixed on master if you're able to work from source. |
cheers! looking forward to it |
I have a very simple Python app that looks like
When I don't run the server, I'm not able to kill the app with
Ctrl-C
, no matter how many times I press it. Is grpc trapping the signal somewhere? This reproduces for me in Python and Node, haven't tried other implementations.The text was updated successfully, but these errors were encountered: