qml.concurrency.executors.native.conc_futures.ThreadPoolExec¶
- class ThreadPoolExec(max_workers=None, persist=False, **kwargs)[source]¶
Bases:
PyNativeExec
concurrent.futures.ThreadPoolExecutor class executor.
This executor wraps Python standard library concurrent.futures.ThreadPoolExecutor interface, and provides support for execution using multiple threads. The threading executor may not provide execution speed-ups for tasks when using a GIL-enabled Python.
Note
All calls to the executor are synchronous, and do not currently support the use of futures as a return object.
- Parameters:
max_workers – the maximum number of concurrent units (threads) to use
persist – allow the executor backend to persist between executions. True avoids potentially costly set-up and tear-down, where supported. Explicit calls to
shutdown
will set this to False.**kwargs – Keyword arguments to pass-through to the executor backend.
Attributes
Indicates whether the executor will maintain its configured state between calls.
The size of the worker pool for the given executor.
- persist¶
Indicates whether the executor will maintain its configured state between calls.
- size¶
The size of the worker pool for the given executor.
Methods
map
(fn, *args, **kwargs)Single iterable map for batching execution of fn over data entries.
shutdown
()Shutdown the executor backend, if valid.
starmap
(fn, args, **kwargs)Single iterable map for batching execution of fn over data entries, with each entry being a tuple of arguments to fn.
submit
(fn, *args, **kwargs)Single function submission for remote execution with provided args.
- map(fn, *args, **kwargs)¶
Single iterable map for batching execution of fn over data entries. Length of every entry in
*args
must be consistent. kwargs are assumed as broadcastable to each function call.
- shutdown()¶
Shutdown the executor backend, if valid.
- starmap(fn, args, **kwargs)¶
Single iterable map for batching execution of fn over data entries, with each entry being a tuple of arguments to fn.
- submit(fn, *args, **kwargs)¶
Single function submission for remote execution with provided args.