27
27
cdef extern from *:
28
28
ctypedef char* const_char_ptr "const char*"
30
from cpython cimport PyErr_CheckSignals
32
from libzmq cimport zmq_strerror, zmq_errno
30
from libzmq cimport zmq_strerror, zmq_errno as zmq_errno_c
34
32
from zmq.utils.strtypes import bytes
48
46
# Python 3: decode bytes to unicode str
49
47
return str_e.decode()
52
class ZMQBaseError(Exception):
53
"""Base exception class for 0MQ errors in Python."""
57
class ZMQError(ZMQBaseError):
58
"""Wrap an errno style error.
63
The ZMQ errno or None. If None, then ``zmq_errno()`` is called and
66
Description of the error or None.
70
def __init__(self, errno=None, msg=None):
71
"""Wrap an errno style error.
76
The ZMQ errno or None. If None, then ``zmq_errno()`` is called and
79
Description of the error or None.
84
if type(errno) == int:
87
self.strerror = strerror(errno)
92
self.strerror = str(errno)
95
# flush signals, because there could be a SIGINT
96
# waiting to pounce, resulting in uncaught exceptions.
97
# Doing this here means getting SIGINT during a blocking
98
# libzmq call will raise a *catchable* KeyboardInterrupt
105
return "ZMQError('%s')"%self.strerror
108
class ZMQBindError(ZMQBaseError):
109
"""An error for ``Socket.bind_to_random_port()``.
113
.Socket.bind_to_random_port
118
class NotDone(ZMQBaseError):
119
"""Raised when timeout is reached while waiting for 0MQ to finish with a Message
123
.MessageTracker.wait : object for tracking when ZeroMQ is done
128
__all__ = ['strerror', 'ZMQBaseError', 'ZMQBindError', 'ZMQError', 'NotDone']
52
Return the integer errno of the most recent zmq error.
56
__all__ = ['strerror', 'zmq_errno']