当前位置: 首页>>代码示例>>Python>>正文


Python zmq.ContextTerminated方法代码示例

本文整理汇总了Python中zmq.ContextTerminated方法的典型用法代码示例。如果您正苦于以下问题:Python zmq.ContextTerminated方法的具体用法?Python zmq.ContextTerminated怎么用?Python zmq.ContextTerminated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在zmq的用法示例。


在下文中一共展示了zmq.ContextTerminated方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: mainloop_recv

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import ContextTerminated [as 别名]
def mainloop_recv(self):
        try:
            while True:
                if self._frsock.closed:
                    break

                msg = loadb(self._frsock.recv(copy=False).bytes)
                identifier, type, payload = msg
                self._dispatcher.dispatch(type, self, identifier, payload)
        except zmq.ContextTerminated:
            pass
        except zmq.ZMQError as e:
            if self._tosock.closed:
                logger.warning('Recv socket closed unexpectedly.')
            else:
                raise e 
开发者ID:vacancy,项目名称:Jacinle,代码行数:18,代码来源:cs.py

示例2: run

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import ContextTerminated [as 别名]
def run(self):
        context = zmq.Context()
        frontend = context.socket(zmq.ROUTER)
        frontend.bind('tcp://*:5570')

        backend = context.socket(zmq.DEALER)
        backend.bind('inproc://backend')

        worker = ParameterWorker(context)
        worker.start()

        try:
            zmq.proxy(frontend, backend)
        except zmq.ContextTerminated:
            frontend.close()
            backend.close() 
开发者ID:yl-1993,项目名称:hfsoftmax,代码行数:18,代码来源:paramserver.py

示例3: _zmq_catch_error

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import ContextTerminated [as 别名]
def _zmq_catch_error(name):
    try:
        yield
    except zmq.ContextTerminated:
        logger.info("[{}] Context terminated.".format(name))
        raise DataFlowTerminated()
    except zmq.ZMQError as e:
        if e.errno == errno.ENOTSOCK:       # socket closed
            logger.info("[{}] Socket closed.".format(name))
            raise DataFlowTerminated()
        else:
            raise
    except Exception:
        raise 
开发者ID:tensorpack,项目名称:dataflow,代码行数:16,代码来源:parallel.py

示例4: receive_message

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import ContextTerminated [as 别名]
def receive_message(socket, blocking=True):
        flags = 0 if blocking else zmq.NOBLOCK
        try:
            cmd, data = socket.recv_multipart(flags=flags)
            return cmd, data
        except zmq.Again:
            return None, None
        except zmq.ContextTerminated:
            print("Context terminated ..")
            return None, None
        except KeyboardInterrupt:
            return None, None 
开发者ID:RobinDavid,项目名称:idasec,代码行数:14,代码来源:broker.py

示例5: atest_ctxterm

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import ContextTerminated [as 别名]
def atest_ctxterm(self):
        s = self.context.socket(zmq.REP)
        t = Thread(target=self.context.term)
        t.start()
        self.assertRaises(ContextTerminated, s.recv, zmq.NOBLOCK)
        self.assertRaisesErrno(zmq.TERM, s.recv, zmq.NOBLOCK)
        s.close()
        t.join() 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:10,代码来源:test_error.py

示例6: _zmq_catch_error

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import ContextTerminated [as 别名]
def _zmq_catch_error(name):
    try:
        yield
    except zmq.ContextTerminated:
        print("[{}] Context terminated.".format(name))
        raise Exception
    except zmq.ZMQError as e:
        if e.errno == errno.ENOTSOCK:       # socket closed
            print("[{}] Socket closed.".format(name))
            raise Exception
        else:
            raise
    except Exception:
        raise 
开发者ID:chenyilun95,项目名称:tf-cpn,代码行数:16,代码来源:data_provider.py

示例7: mainloop_send

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import ContextTerminated [as 别名]
def mainloop_send(self):
        try:
            while True:
                if self._tosock.closed:
                    break

                job = self._send_queue.get()
                self._tosock.send_multipart([job.identifier, dumpb(job.payload)], copy=False)
        except zmq.ContextTerminated:
            pass
        except zmq.ZMQError as e:
            if self._tosock.closed:
                logger.warning('Send socket closed unexpectedly.')
            else:
                raise e 
开发者ID:vacancy,项目名称:Jacinle,代码行数:17,代码来源:cs.py

示例8: recv

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import ContextTerminated [as 别名]
def recv(self):
        try:
            return loadb(self._sock.recv(copy=False).bytes)
        except zmq.ContextTerminated:
            pass 
开发者ID:vacancy,项目名称:Jacinle,代码行数:7,代码来源:gather.py

示例9: mainloop_send

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import ContextTerminated [as 别名]
def mainloop_send(self):
        try:
            while True:
                job = self._send_queue.get()
                self._sock.send(dumpb(job), copy=False)
        except zmq.ContextTerminated:
            pass 
开发者ID:vacancy,项目名称:Jacinle,代码行数:9,代码来源:gather.py

示例10: run

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import ContextTerminated [as 别名]
def run(self):
        self.clients = defaultdict(self.ClientState)
        try:
            while True:
                msg = loads(self.c2s_socket.recv(copy=False))
                ident, state, reward, isOver = msg
                client = self.clients[ident]
                if client.ident is None:
                    client.ident = ident
                # maybe check history and warn about dead client?
                self._process_msg(client, state, reward, isOver)
        except zmq.ContextTerminated:
            logger.info("[Simulator] Context was terminated.") 
开发者ID:tensorpack,项目名称:tensorpack,代码行数:15,代码来源:simulator.py


注:本文中的zmq.ContextTerminated方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。