當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。