dwave.cloud.computation.Future.as_completed#
- static Future.as_completed(fs, timeout=None)[source]#
Yield Futures objects as they complete.
Returns an iterator over the specified list of
Future
objects that yields those objects as they complete. Completion occurs when the submitted job is finished or cancelled.Emulates the behavior of the concurrent.futures.as_completed() function.
- Parameters:
- Returns:
Listed
Future
objects as they complete.- Return type:
Generator (
Future
objects)- Raises:
exceeded. –
Examples
This example creates a solver using the local system’s default D-Wave Cloud Client configuration file, submits a simple QUBO problem to a remote D-Wave resource 3 times for differing numbers of samples, and yields timing information for each job as it completes.
>>> import dwave.cloud as dc >>> client = dc.Client.from_config() >>> solver = client.get_solver() >>> u, v = next(iter(solver.edges)) >>> Q = {(u, u): -1, (u, v): 0, (v, u): 2, (v, v): -1} >>> computation = [solver.sample_qubo(Q, num_reads=1000), ... solver.sample_qubo(Q, num_reads=50), ... solver.sample_qubo(Q, num_reads=10)] >>> for tasks in dc.computation.Future.as_completed(computation, timeout=10) ... print(tasks.timing) ... {'total_real_time': 17318, ... 'qpu_readout_time_per_sample': 123} {'total_real_time': 10816, ... 'qpu_readout_time_per_sample': 123} {'total_real_time': 26285, ... 'qpu_readout_time_per_sample': 123} ... >>> client.close()