Python zmq 模块,error() 实例源码

我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用zmq.error()

项目:zanph    作者:zanph    | 项目源码 | 文件源码
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.
        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)
项目:trex-http-proxy    作者:alwye    | 项目源码 | 文件源码
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.
        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)
项目:trex-http-proxy    作者:alwye    | 项目源码 | 文件源码
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.
        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)
项目:trex-http-proxy    作者:alwye    | 项目源码 | 文件源码
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.
        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)
项目:trex-http-proxy    作者:alwye    | 项目源码 | 文件源码
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.
        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)
项目:trex-http-proxy    作者:alwye    | 项目源码 | 文件源码
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.
        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)
项目:piwheels    作者:bennuttall    | 项目源码 | 文件源码
def handle_fs_request(self, queue):
        """
        Handle incoming messages from :class:`FsClient` instances.
        """
        msg, *args = queue.recv_pyobj()
        try:
            handler = {
                'EXPECT': self.do_expect,
                'VERIFY': self.do_verify,
                'STATVFS': self.do_statvfs,
            }[msg]
            result = handler(*args)
        except Exception as exc:
            self.logger.error('error handling fs request: %s', msg)
            queue.send_pyobj(['ERR', exc])
        else:
            queue.send_pyobj(['OK', result])
项目:qudi    作者:Ulm-IQO    | 项目源码 | 文件源码
def iopub_handler(self, msg):
        # handle some of these messages:
        # stream, display_data, data_pub, execute_input, execute_result
        # error, status, clear_output
        logging.debug( "iopub received: %s" % msg)
项目:qudi    作者:Ulm-IQO    | 项目源码 | 文件源码
def transform_ast(self, node):
        """Apply the AST transformations from self.ast_transformers

        Parameters
        ----------
        node : ast.Node
          The root node to be transformed. Typically called with the ast.Module
          produced by parsing user input.

        Returns
        -------
        An ast.Node corresponding to the node it was called with. Note that it
        may also modify the passed object, so don't rely on references to the
        original AST.
        """
        for transformer in self.ast_transformers:
            try:
                node = transformer.visit(node)
            except InputRejected:
                # User-supplied AST transformers can reject an input by raising
                # an InputRejected.  Short-circuit in this case so that we
                # don't unregister the transform.
                raise
            except Exception:
                warn("AST transformer %r threw an error. It will be unregistered." % transformer)
                self.ast_transformers.remove(transformer)

        if self.ast_transformers:
            ast.fix_missing_locations(node)
        return node
项目:piwheels    作者:bennuttall    | 项目源码 | 文件源码
def handle_db_request(self, queue):
        """
        Handle incoming requests from :class:`DbClient` instances.
        """
        address, empty, msg = queue.recv_multipart()
        msg, *args = pickle.loads(msg)
        try:
            handler = {
                'ALLPKGS': self.do_allpkgs,
                'ALLVERS': self.do_allvers,
                'NEWPKG': self.do_newpkg,
                'NEWVER': self.do_newver,
                'LOGBUILD': self.do_logbuild,
                'PKGFILES': self.do_pkgfiles,
                'PKGEXISTS': self.do_pkgexists,
                'GETABIS': self.do_getabis,
                'GETPYPI': self.do_getpypi,
                'SETPYPI': self.do_setpypi,
                'GETSTATS': self.do_getstats,
            }[msg]
            result = handler(*args)
        except Exception as exc:
            self.logger.error('Error handling db request: %s', msg)
            # REP *must* send a reply even when stuff goes wrong
            # otherwise the send/recv cycle that REQ/REP depends
            # upon breaks
            queue.send_multipart([address, empty,
                                  pickle.dumps(['ERR', str(exc)])])
        else:
            queue.send_multipart([address, empty,
                                  pickle.dumps(['OK', result])])
项目:qudi    作者:Ulm-IQO    | 项目源码 | 文件源码
def run_code(self, code_obj, result=None):
        """Execute a code object.
        When an exception occurs, self.showtraceback() is called to display a
        traceback.
        Parameters
        ----------
        code_obj : code object
          A compiled code object, to be executed
        result : ExecutionResult, optional
          An object to store exceptions that occur during execution.
        Returns
        -------
        False : successful execution.
        True : an error occurred.
        """
        # Set our own excepthook in case the user code tries to call it
        # directly, so that the IPython crash handler doesn't get triggered
        old_excepthook, sys.excepthook = sys.excepthook, self.excepthook

        # we save the original sys.excepthook in the instance, in case config
        # code (such as magics) needs access to it.
        self.sys_excepthook = old_excepthook
        outflag = 1  # happens in more places, so it's easier as default
        try:
            try:
                #self.hooks.pre_run_code_hook()
                #rprint('Running code', repr(code_obj)) # dbg
                exec(code_obj, self.user_global_ns, self.user_ns)
            finally:
                # Reset our crash handler in place
                sys.excepthook = old_excepthook
        except SystemExit as e:
            if result is not None:
                result.error_in_exec = e
            self.showtraceback(exception_only=True)
            warn("To exit: use 'exit', 'quit', or Ctrl-D.", level=1)
        #except self.custom_exceptions:
        #    etype, value, tb = sys.exc_info()
        #    if result is not None:
        #        result.error_in_exec = value
        #    self.CustomTB(etype, value, tb)
        except:
            if result is not None:
                result.error_in_exec = sys.exc_info()[1]
            self.showtraceback()
        else:
            outflag = 0
        return outflag
项目:piwheels    作者:bennuttall    | 项目源码 | 文件源码
def handle_file(self, queue):
        """
        Handle incoming file-transfer messages from build slaves.

        The file transfer protocol is in some ways very simple (see the chart
        in the :doc:`slaves` chapter for an overview of the message sequence)
        and in some ways rather complex (read the ZeroMQ guide chapter on file
        transfers for more detail on why multiple messages must be allowed in
        flight simultaneously).

        The "normal" state for a file transfer is to be requesting and
        receiving chunks. Anything else, including redundant re-sends, and
        transfer completion is handled as an exceptional case.
        """
        address, msg, *args = queue.recv_multipart()
        try:
            try:
                transfer = self.active[address]
            except KeyError:
                transfer = self.new_transfer(msg, *args)
                self.active[address] = transfer
            else:
                self.current_transfer(transfer, msg, *args)
        except TransferDone as exc:
            self.logger.info(str(exc))
            del self.active[address]
            self.complete[transfer.slave_id] = transfer
            queue.send_multipart([address, b'DONE'])
        except TransferIgnoreChunk as exc:
            self.logger.debug(str(exc))
        except TransferError as exc:
            self.logger.error(str(exc))
            # XXX Delete the transfer object?
            # XXX Remove transfer from slave?
        else:
            fetch_range = transfer.fetch()
            while fetch_range:
                queue.send_multipart([
                    address, b'FETCH',
                    str(fetch_range.start).encode('ascii'),
                    str(len(fetch_range)).encode('ascii')
                ])
                fetch_range = transfer.fetch()