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


Python asyncio.ensure_future方法代码示例

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


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

示例1: launch

# 需要导入模块: from zmq import asyncio [as 别名]
# 或者: from zmq.asyncio import ensure_future [as 别名]
def launch(self):
        """
        Launches an asynchronous loop executors for respective task.
        """
        # check if receive mode enabled
        if self.__receive_mode:
            if self.__logging:
                logger.debug("Launching NetGear asynchronous generator!")
            # run loop executor for Receiver asynchronous generator
            self.loop.run_in_executor(None, self.recv_generator)
            # return instance
            return self
        else:
            # Otherwise launch Server handler
            if self.__logging:
                logger.debug("Creating NetGear asynchronous server handler!")
            # create task for Server Handler
            self.task = asyncio.ensure_future(self.__server_handler(), loop=self.loop)
            # return instance
            return self 
开发者ID:abhiTronix,项目名称:vidgear,代码行数:22,代码来源:netgear_async.py

示例2: shutdown

# 需要导入模块: from zmq import asyncio [as 别名]
# 或者: from zmq.asyncio import ensure_future [as 别名]
def shutdown(self):
        self._dispatcher.remove_send_message(self._connection)
        self._dispatcher.remove_send_last_message(self._connection)
        if self._event_loop is None:
            return
        if self._event_loop.is_closed():
            return

        if self._event_loop.is_running():
            if self._auth is not None:
                self._event_loop.call_soon_threadsafe(self._auth.stop)
        else:
            # event loop was never started, so the only Task that is running
            # is the Auth Task.
            self._event_loop.run_until_complete(self._stop_auth())

        asyncio.ensure_future(self._stop(), loop=self._event_loop) 
开发者ID:hyperledger,项目名称:sawtooth-core,代码行数:19,代码来源:interconnect.py

示例3: launch

# 需要导入模块: from zmq import asyncio [as 别名]
# 或者: from zmq.asyncio import ensure_future [as 别名]
def launch(self, websocket_port, message_max_size):
        async def receive_from_engine_worker_loop():
            await self.wait_for_start()
            while self.is_running():
                await self._receive_from_engine_worker_helper()

        async def heartbeat_loop():
            await self.wait_for_start()
            while self.is_running():
                await asyncio.sleep(self._timeout)
                await self._heartbeat_helper()

        asyncio.ensure_future(receive_from_engine_worker_loop())
        asyncio.ensure_future(heartbeat_loop())

        super().launch(websocket_port, message_max_size) 
开发者ID:cmusatyalab,项目名称:gabriel,代码行数:18,代码来源:server_runner.py

示例4: _stop

# 需要导入模块: from zmq import asyncio [as 别名]
# 或者: from zmq.asyncio import ensure_future [as 别名]
def _stop(self):
        self._dispatcher.remove_send_message(self._connection)
        self._dispatcher.remove_send_last_message(self._connection)
        yield from self._stop_auth()

        for task in self._cancellable_tasks:
            task.cancel()

        asyncio.ensure_future(self._stop_event_loop(), loop=self._event_loop) 
开发者ID:hyperledger,项目名称:sawtooth-core,代码行数:11,代码来源:interconnect.py

示例5: start

# 需要导入模块: from zmq import asyncio [as 别名]
# 或者: from zmq.asyncio import ensure_future [as 别名]
def start(self):
        """Start ZAP authentication"""
        super().start()
        self.__poller = zmq.asyncio.Poller()
        self.__poller.register(self.zap_socket, zmq.POLLIN)
        self.__task = asyncio.ensure_future(self.__handle_zap()) 
开发者ID:hyperledger,项目名称:indy-plenum,代码行数:8,代码来源:authenticator.py

示例6: createTask

# 需要导入模块: from zmq import asyncio [as 别名]
# 或者: from zmq.asyncio import ensure_future [as 别名]
def createTask(self, msgID, coro, timeout=0):
        """
        Create a new task for msgID.
        """
        if timeout > 0:
            coro = asyncio.wait_for(coro, timeout)
        task = asyncio.ensure_future(coro, loop=self.loop)
        self.tasks[msgID] = task

        def clean(fut, msgID=msgID):
            if msgID in self.tasks:
                del self.tasks[msgID]

        task.add_done_callback(clean) 
开发者ID:feihoo87,项目名称:QuLab,代码行数:16,代码来源:rpc.py

示例7: cancelRemoteTask

# 需要导入模块: from zmq import asyncio [as 别名]
# 或者: from zmq.asyncio import ensure_future [as 别名]
def cancelRemoteTask(self, addr, msgID):
        """
        Try to cancel remote task.
        """
        asyncio.ensure_future(self.sendto(RPC_CANCEL + msgID, addr),
                              loop=self.loop) 
开发者ID:feihoo87,项目名称:QuLab,代码行数:8,代码来源:rpc.py

示例8: on_ping

# 需要导入模块: from zmq import asyncio [as 别名]
# 或者: from zmq.asyncio import ensure_future [as 别名]
def on_ping(self, source, data):
        log.debug(f"received ping from {source}")
        asyncio.ensure_future(self.pong(source), loop=self.loop) 
开发者ID:feihoo87,项目名称:QuLab,代码行数:5,代码来源:rpc.py

示例9: remoteCall

# 需要导入模块: from zmq import asyncio [as 别名]
# 或者: from zmq.asyncio import ensure_future [as 别名]
def remoteCall(self, addr, methodNane, args=(), kw=None):
        if kw is None:
            kw = {}
        if 'timeout' in kw:
            timeout = kw['timeout']
        else:
            timeout = self._client_defualt_timeout
        msg = pack((methodNane, args, kw))
        msgID = randomID()
        asyncio.ensure_future(self.request(addr, msgID, msg), loop=self.loop)
        return self.createPending(addr, msgID, timeout) 
开发者ID:feihoo87,项目名称:QuLab,代码行数:13,代码来源:rpc.py

示例10: start

# 需要导入模块: from zmq import asyncio [as 别名]
# 或者: from zmq.asyncio import ensure_future [as 别名]
def start(self):
        super().start()
        self.zmq_ctx = zmq.asyncio.Context.instance()
        self.zmq_main_task = asyncio.ensure_future(self.run(), loop=self.loop) 
开发者ID:feihoo87,项目名称:QuLab,代码行数:6,代码来源:rpc.py


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