Python concurrent.futures.wrap_future() Examples

The following are 7 code examples of concurrent.futures.wrap_future(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module concurrent.futures , or try the search function .
Example #1
Source File: base_events.py    From Fluid-Designer with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #2
Source File: base_events.py    From ironpython3 with Apache License 2.0 6 votes vote down vote up
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) 
Example #3
Source File: base_events.py    From Imogen with MIT License 5 votes vote down vote up
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) 
Example #4
Source File: base_events.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #5
Source File: base_events.py    From odoo13-x64 with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #6
Source File: base_events.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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) 
Example #7
Source File: base_events.py    From android_universal with MIT License 5 votes vote down vote up
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)