本文整理汇总了Python中zmq.error方法的典型用法代码示例。如果您正苦于以下问题:Python zmq.error方法的具体用法?Python zmq.error怎么用?Python zmq.error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zmq
的用法示例。
在下文中一共展示了zmq.error方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: configure_curve
# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import error [as 别名]
def configure_curve(self, domain='*', location=None):
"""Configure CURVE authentication for a given domain.
CURVE authentication uses a directory that holds all public client certificates,
i.e. their public keys.
To cover all domains, use "*".
You can add and remove certificates in that directory at any time.
To allow all client keys without checking, specify CURVE_ALLOW_ANY for the location.
"""
# If location is CURVE_ALLOW_ANY then allow all clients. Otherwise
# treat location as a directory that holds the certificates.
self.log.debug("Configure curve: %s[%s]", domain, location)
if location == CURVE_ALLOW_ANY:
self.allow_any = True
else:
self.allow_any = False
try:
self.certs[domain] = load_certificates(location)
except Exception as e:
self.log.error("Failed to load CURVE certs from %s: %s", location, e)
示例2: configure_curve
# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import error [as 别名]
def configure_curve(self, domain='*', location=None):
"""Configure CURVE authentication for a given domain.
CURVE authentication uses a directory that holds all public client certificates,
i.e. their public keys.
To cover all domains, use "*".
You can add and remove certificates in that directory at any time. configure_curve must be called
every time certificates are added or removed, in order to update the Authenticator's state
To allow all client keys without checking, specify CURVE_ALLOW_ANY for the location.
"""
# If location is CURVE_ALLOW_ANY then allow all clients. Otherwise
# treat location as a directory that holds the certificates.
self.log.debug("Configure curve: %s[%s]", domain, location)
if location == CURVE_ALLOW_ANY:
self.allow_any = True
else:
self.allow_any = False
try:
self.certs[domain] = load_certificates(location)
except Exception as e:
self.log.error("Failed to load CURVE certs from %s: %s", location, e)
示例3: recv
# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import error [as 别名]
def recv(self, return_data=None):
"""
A Receiver end method, that extracts received frames synchronously from monitored deque, while maintaining a
fixed-length frame buffer in the memory, and blocks the thread if the deque is full.
Parameters:
return_data (any): inputs return data _(of any datatype)_, for sending back to Server.
**Returns:** A n-dimensional numpy array.
"""
# check whether `receive mode` is activated
if not (self.__receive_mode):
# raise value error and exit
self.__terminate = True
raise ValueError(
"[NetGear:ERROR] :: `recv()` function cannot be used while receive_mode is disabled. Kindly refer vidgear docs!"
)
# handle bi-directional return data
if (self.__bi_mode or self.__multiclient_mode) and not (return_data is None):
self.__return_data = return_data
# check whether or not termination flag is enabled
while not self.__terminate:
try:
# check if queue is empty
if len(self.__queue) > 0:
return self.__queue.popleft()
else:
time.sleep(0.00001)
continue
except KeyboardInterrupt:
self.__terminate = True
break
# otherwise return NoneType
return None
示例4: configure_curve_callback
# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import error [as 别名]
def configure_curve_callback(self, domain='*', credentials_provider=None):
"""Configure CURVE authentication for a given domain.
CURVE authentication using a callback function validating
the client public key according to a custom mechanism, e.g. checking the
key against records in a db. credentials_provider is an object of a class which
implements a callback method accepting two parameters (domain and key), e.g.::
class CredentialsProvider(object):
def __init__(self):
...e.g. db connection
def callback(self, domain, key):
valid = ...lookup key and/or domain in db
if valid:
logging.info('Autorizing: {0}, {1}'.format(domain, key))
return True
else:
logging.warning('NOT Autorizing: {0}, {1}'.format(domain, key))
return False
To cover all domains, use "*".
To allow all client keys without checking, specify CURVE_ALLOW_ANY for the location.
"""
self.allow_any = False
if credentials_provider is not None:
self.credentials_providers[domain] = credentials_provider
else:
self.log.error("None credentials_provider provided for domain:%s",domain)