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


Python futures.wrap_future方法代码示例

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


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

示例1: run_in_executor

# 需要导入模块: from concurrent import futures [as 别名]
# 或者: from concurrent.futures import wrap_future [as 别名]
def run_in_executor(self, executor, func, *args):
        if (coroutines.iscoroutine(func)
        or coroutines.iscoroutinefunction(func)):
            raise TypeError("coroutines cannot be used with run_in_executor()")
        self._check_closed()
        if isinstance(func, events.Handle):
            assert not args
            assert not isinstance(func, events.TimerHandle)
            if func._cancelled:
                f = futures.Future(loop=self)
                f.set_result(None)
                return f
            func, args = func._callback, func._args
        if executor is None:
            executor = self._default_executor
            if executor is None:
                executor = concurrent.futures.ThreadPoolExecutor(_MAX_WORKERS)
                self._default_executor = executor
        return futures.wrap_future(executor.submit(func, *args), loop=self) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:21,代码来源:base_events.py

示例2: run_in_executor

# 需要导入模块: from concurrent import futures [as 别名]
# 或者: from concurrent.futures import wrap_future [as 别名]
def run_in_executor(self, executor, func, *args):
        self._check_closed()
        if self._debug:
            self._check_callback(func, 'run_in_executor')
        if executor is None:
            executor = self._default_executor
            if executor is None:
                executor = concurrent.futures.ThreadPoolExecutor()
                self._default_executor = executor
        return futures.wrap_future(
            executor.submit(func, *args), loop=self) 
开发者ID:CedricGuillemet,项目名称:Imogen,代码行数:13,代码来源:base_events.py

示例3: run_in_executor

# 需要导入模块: from concurrent import futures [as 别名]
# 或者: from concurrent.futures import wrap_future [as 别名]
def run_in_executor(self, executor, func, *args):
        self._check_closed()
        if self._debug:
            self._check_callback(func, 'run_in_executor')
        if executor is None:
            executor = self._default_executor
            if executor is None:
                executor = concurrent.futures.ThreadPoolExecutor()
                self._default_executor = executor
        return futures.wrap_future(executor.submit(func, *args), loop=self) 
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:12,代码来源:base_events.py


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