def func(x): with warnings.catch_warnings(record=True) as record: with local_client() as c: x = c.submit(inc, x) result = x.result() assert any("worker_client" in str(r.message) for r in record) return result
def func(): with local_client() as ee: x = ee.submit(inc, 1, workers=a_address) y = ee.submit(inc, 2, workers=b_address) xx, yy = ee.gather([x, y]) return xx, yy
def func(): with local_client() as ee: x = ee.submit(inc, 1, workers=a_address) y = ee.submit(inc, 2, workers=b_address) xx, yy = ee.gather([x, y]) return xx, yy
def func(x): with warnings.catch_warnings(record=True) as record: with local_client() as c: x = c.submit(inc, x) result = x.result() assert any("worker_client" in str(r.message) for r in record) return result
def produce(n): with local_client() as c: x = c.channel('x') for i in range(n): future = c.submit(slowinc, i, delay=0.01, key='f-%d' % i) x.append(future) x.flush()
def consume(): with local_client() as c: x = c.channel('x') y = c.channel('y') last = 0 for i, future in enumerate(x): last = c.submit(add, future, last, key='add-' + future.key) y.append(last)
def produce(n): with local_client() as c: x = c.channel('x') for i in range(n): future = c.submit(slowinc, i, delay=0.01, key='f-%d' % i) x.append(future) x.flush()
def mysum(): result = 0 sub_tasks = [delayed(double)(i) for i in range(100)] with local_client() as lc: futures = lc.compute(sub_tasks) for f in as_completed(futures): result += f.result() return result
def fib(n): if n < 2: return n else: with local_client() as c: a = c.submit(fib, n - 1) b = c.submit(fib, n - 2) a, b = c.gather([a, b]) return a + b
def func(): with local_client() as c: correct = True for data in [[1, 2], (1, 2), {1, 2}]: futures = c.scatter(data) correct &= type(futures) == type(data) o = object() futures = c.scatter({'x': o}) correct &= c.worker.data['x'] is o return correct
def func(): with local_client() as c: correct = True for data in [[1, 2], (1, 2), {1, 2}]: futures = c.scatter(data) correct &= type(futures) == type(data) o = object() futures = c.scatter({'x': o}) correct &= c.worker.data['x'] is o return correct
def func(): with local_client() as c: futures = c.scatter([1, 2, 3, 4, 5]) assert isinstance(futures, (list, tuple)) assert len(futures) == 5 x = c.worker.data.copy() y = {f.key: i for f, i in zip(futures, [1, 2, 3, 4, 5])} assert x == y total = c.submit(sum, futures) return total.result()
def func(): with local_client() as c: futures = c.scatter([1, 2, 3, 4, 5]) assert isinstance(futures, (list, tuple)) assert len(futures) == 5 x = c.worker.data.copy() y = {f.key: i for f, i in zip(futures, [1, 2, 3, 4, 5])} assert x == y total = c.submit(sum, futures) return total.result()
def func(x): with local_client() as c: x = c.submit(inc, x) y = c.submit(double, x) result = x.result() + y.result() return result
def func(x): with local_client() as c: x = c.submit(inc, x) y = c.submit(double, x) result = x.result() + y.result() return result
def f(): with local_client() as lc: return lc.loop is lc.worker.loop