[zeromq-dev] shutting down proxy device cleanly with pyzmq

Sideropoulos, Alexander alexander at thequery.net
Wed Oct 16 06:38:18 CEST 2013

I cannot seem to understand the proper use (read: shutting down) of a
ZeroMQ proxy/device in Python.

For example, once a ThreadProxy has been start()'ed, how does one
successfully join() to it? The thread has to actually want to exit for the
join() to ever return, right?

My current approach is to catch the user's KeyboardInterrupt in the main
thread and term() the shared Context. This causes all threads using the
same Context to error out nicely, but the proxy does not handle this

Exception in thread Thread-5:
> Traceback (most recent call last):
>   File
> "/usr/local/Cellar/python3/3.3.1/Frameworks/Python.framework/Versions/3.3/lib/python3.3/threading.py",
> line 639, in _bootstrap_inner
>     self.run()
>   File
> "/usr/local/Cellar/python3/3.3.1/Frameworks/Python.framework/Versions/3.3/lib/python3.3/threading.py",
> line 596, in run
>     self._target(*self._args, **self._kwargs)
>   File
> "/usr/local/lib/python3.3/site-packages/zmq/devices/proxydevice.py", line
> 84, in run
>     rc = zmq.proxy(ins, outs, mons)
>   File "_device.pyx", line 82, in zmq.core._device.proxy
> (zmq/core/_device.c:1325)
>   File "checkrc.pxd", line 18, in zmq.core.checkrc._check_rc
> (zmq/core/_device.c:1517)
> zmq.error.ContextTerminated: Context was terminated

What are the possible approaches? Or is a pull request in order for proper
handling proxy shutdown?

Alexander Sideropoulos
alexander at thequery.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20131015/ddca8784/attachment.htm>

More information about the zeromq-dev mailing list