Reference

futured

class futured.futured[source]

Bases: functools.partial

A partial function which returns futures.

classmethod items(iterable: Iterable, **kwargs) → Iterator[source]

Generate key, result pairs as completed from futures.

Parameters
  • iterable – key, future pairs

  • kwargs – as completed options, e.g., timeout

map(*iterables: Iterable, **kwargs) → Iterator[source]

Asynchronously map function.

Parameters

kwargs – keyword options for results()

mapzip(iterable: Iterable, **kwargs) → Iterator[source]

Generate arg, result pairs as completed.

Parameters

kwargs – keyword options for items()

classmethod results(fs: Iterable, *, as_completed=False, **kwargs) → Iterator[source]

Generate results concurrently from futures, by default in order.

Parameters
  • fs – iterable of futures

  • kwargs (as_completed,) – generate results as completed with options, e.g., timeout

starmap(iterable: Iterable, **kwargs) → Iterator[source]

Asynchronously starmap function.

Parameters

kwargs – keyword options for results()

classmethod stream(fs: MutableSet, **kwargs) → Iterator[source]

Generate futures as completed from a mutable set.

Iteration will consume futures from the set, and it can be updated while in use.

streamzip(queue: Sequence, **kwargs) → Iterator[source]

Generate arg, future pairs as completed from mapping function.

The queue can be extended while in use.

classmethod waiting(*fs, **kwargs)[source]

Return context manager which waits on results().

class futured.threaded[source]

Bases: futured.executed

A partial function executed in its own thread pool.

Executor

alias of concurrent.futures.thread.ThreadPoolExecutor

class futured.processed[source]

Bases: futured.executed

A partial function executed in its own process pool.

Executor

alias of concurrent.futures.process.ProcessPoolExecutor

class futured.distributed

Note

requires dask distributed client

futured.decorated(base: type, **decorators: Callable) → type[source]

Return subclass with decorated methods.

asynced

class futured.asynced[source]

Bases: futured.futured

A partial coroutine.

Anywhere futures are expected, coroutines are also supported.

classmethod items(iterable: Iterable, **kwargs) → Iterator[source]

Generate key, result pairs as completed from futures.

Parameters
  • iterable – key, future pairs

  • kwargs – as completed options, e.g., timeout

classmethod results(fs: Iterable, *, loop=None, as_completed=False, **kwargs) → Iterator[source]

Generate results concurrently from futures, by default in order.

Parameters
  • fs – iterable of futures

  • kwargs (as_completed,) – generate results as completed with options, e.g., timeout

run(*args, **kwargs)[source]

Synchronously call and run coroutine or asynchronous iterator.

class futured.looped(aiterable: AsyncIterable, *, loop=None)[source]

Wrap an asynchronous iterable into an iterator.

Analogous to loop.run_until_complete for coroutines.

processes

class futured.command(*args, **kwargs)[source]

Bases: subprocess.Popen

Asynchronous subprocess with a future compatible interface.

__init__(*args, **kwargs)[source]

Create new Popen instance.

__iter__()[source]

Return output lines.

__or__(other: Iterable) → futured.command[source]

Alias of pipe().

classmethod coroutine(*args, shell=False, **kwargs)[source]

Create a subprocess coroutine, suitable for timeouts.

pipe(*args, **kwargs) → futured.command[source]

Pipe stdout to the next command’s stdin.

result(**kwargs) → AnyStr[source]

Return stdout or raise stderr.

futured.forked(values: Iterable, max_workers: int = None) → Iterator[source]

Generate each value in its own child process and wait in the parent.