Python源码示例:concurrent.futures.wrap_future()

示例1
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) 
示例2
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) 
示例3
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) 
示例4
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) 
示例5
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) 
示例6
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) 
示例7
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)