MCPcopy Create free account
hub / github.com/dwavesystems/dwave-cloud-client / wait_multiple

Method wait_multiple

dwave/cloud/computation.py:249–348  ·  view source on GitHub ↗

Wait for multiple :class:`Future` objects to complete. Blocking call that uses an event object to emulate multi-wait for Python. Args: futures (list of Futures): List of :class:`Future` objects to await. min_done (int, optional, default=None

(futures, min_done=None, timeout=None)

Source from the content-addressed store, hash-verified

247
248 @staticmethod
249 def wait_multiple(futures, min_done=None, timeout=None):
250 """Wait for multiple :class:`Future` objects to complete.
251
252 Blocking call that uses an event object to emulate multi-wait for Python.
253
254 Args:
255 futures (list of Futures):
256 List of :class:`Future` objects to await.
257
258 min_done (int, optional, default=None):
259 Minimum required completions to end the waiting. The wait is
260 terminated when this number of results are ready. If None, waits
261 for all the :class:`Future` objects to complete.
262
263 timeout (float, optional, default=None):
264 Maximum number of seconds to await completion. If None, waits
265 indefinitely.
266
267 Returns:
268 Two-tuple of :class:`Future` objects: completed and not completed
269 submitted tasks. Similar to `concurrent.futures.wait()` method's
270 returned two-tuple of `done` and `not_done` sets.
271
272 See Also:
273 :func:`as_completed` for a blocking iterable of resolved futures
274 similar to `concurrent.futures.as_completed()` method.
275
276 Examples:
277 This example creates a solver using the local system's default
278 D-Wave Cloud Client configuration file, submits a simple QUBO
279 problem to a remote D-Wave resource 3 times for differing numbers of
280 samples, and waits for sampling to complete on any two of the
281 submissions. The wait ends with the completion of two submissions
282 while the third is still in progress. (A more typical approach would
283 use something like
284 :code:`first = next(Future.as_completed(computation))` instead.)
285
286 >>> import dwave.cloud as dc
287 >>> client = dc.Client.from_config() # doctest: +SKIP
288 >>> solver = client.get_solver() # doctest: +SKIP
289 >>> u, v = next(iter(solver.edges)) # doctest: +SKIP
290 >>> Q = {(u, u): -1, (u, v): 0, (v, u): 2, (v, v): -1} # doctest: +SKIP
291 >>> computation = [solver.sample_qubo(Q, num_reads=1000),
292 ... solver.sample_qubo(Q, num_reads=50),
293 ... solver.sample_qubo(Q, num_reads=10)] # doctest: +SKIP
294 >>> dc.computation.Future.wait_multiple(computation, min_done=1) # doctest: +SKIP
295 ([<dwave.cloud.computation.Future at 0x17dde518>,
296 <dwave.cloud.computation.Future at 0x17ddee80>],
297 [<dwave.cloud.computation.Future at 0x15078080>])
298 >>> print(computation[0].done()) # doctest: +SKIP
299 False
300 >>> print(computation[1].done()) # doctest: +SKIP
301 True
302 >>> print(computation[2].done()) # doctest: +SKIP
303 True
304 >>> client.close() # doctest: +SKIP
305
306 """

Callers 2

as_completedMethod · 0.80
test_wait_manyMethod · 0.80

Calls 6

_add_eventMethod · 0.80
clearMethod · 0.80
doneMethod · 0.80
setMethod · 0.80
_remove_eventMethod · 0.80
waitMethod · 0.45

Tested by 1

test_wait_manyMethod · 0.64