[zeromq-dev] Interrupt recv() with ctrl-c in pyzmq

Pat Collins pat at burned.com
Thu Nov 6 21:15:59 CET 2014

I haven't done this before, but this comes from Python docs about threads:

"Threads interact strangely with interrupts: the KeyboardInterrupt
exception will be received by an arbitrary thread. (When the signal
module is available, interrupts always go to the main thread.)"

source: https://docs.python.org/2/library/thread.html

Given that logic, I'd set up a notifier that sends messages to the
threads to exit cleanly. I suppose you could raise KeyboardInterrupt
yourself in each thread so exit code can stay similar in each thread.

On Thu, Nov 6, 2014 at 2:18 PM,  <jeremy_mclain at selinc.com> wrote:
> I'm trying to figure out how to interrupt recv() using SIGINT signal
> (ctrl-c). It seems to work find ask shown in this example when recv() is
> called on the main thread. http://zguide.zeromq.org/py:interrupt. I can't
> figure out how to get it to work when the recv() is called from a thread
> other than main.
> Any ideas?
> Jeremy McLain
> Schweitzer Engineering Laboratories, Inc.
> 509-336-4443
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Patrick Collins

More information about the zeromq-dev mailing list