-
Notifications
You must be signed in to change notification settings - Fork 60
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
pynng sock.recv() not interruptable #106
Comments
You can work around this by adding a small timeout, inside a while loop, or while checking if some flag for shutdown is up (ex. to stop a thread) with pynng.Sub0(...) as sock:
sock.subscribe("")
sock.dial(addr)
while True: # or not stop_request
try:
msg = sock.recv(timeout=1.0)
except pynng.exceptions.Timeout:
pass |
This behavior cannot be fixed without changes to the underlying nng library; see an issue I opened a couple years ago for a discussion. I'll leave this issue open just as a reference. |
I have tried your solution @ntakouris and it works, thank you. However, I had to abandon it because |
I was playing around with pyzmq and stumbled into the same issue, and I found this SO reply that actually worked. Just sharing for now, haven't tried it with pynng. Will post back if it works. |
If I call
.recv()
on a socket created withoutrecv_timeout
, the call isn't interruptable with ^C.Example:
Hangs indefinitely if I press ^C until a messages comes in.
The text was updated successfully, but these errors were encountered: