tools/perf/cli_tools/soundwave/worker_pool.py
def Run(label, worker, args, items, stream=None):
  """Use a pool of workers to concurrently process a sequence of items.

  Args:
    label: A string displayed by the progress indicator when the job starts.
    worker: A function with the worker implementation. See example above.
    args: An argparse.Namespace() object used to initialize the workers. The
        value of args.processes is the number of processes used by the pool.
    items: An iterable with items to process by the pool of workers.
    stream: A file-like object for the progress indicator output, defaults to
        sys.stdout.

  Returns:
    Total time in seconds spent by the pool to process all items.
  """
  pool = multiprocessing.Pool(
      processes=args.processes, initializer=worker, initargs=(args,))
  time_started = pandas.Timestamp.utcnow()
  try:
    ProgressIndicator(label, pool.imap_unordered(_Worker, items), stream=stream)
    time_finished = pandas.Timestamp.utcnow()
  finally:
    # Ensure resources (e.g. db connections from workers) are freed up.
    pool.terminate()
    pool.join()
  return (time_finished - time_started).total_seconds()
Use a pool of workers to concurrently process a sequence of items.

  Args:
    label: A string displayed by the progress indicator when the job starts.
    worker: A function with the worker implementation. See example above.
    args: An argparse.Namespace() object used to initialize the workers. The
        value of args.processes is the number of processes used by the pool.
    items: An iterable with items to process by the pool of workers.
    stream: A file-like object for the progress indicator output, defaults to
        sys.stdout.

  Returns:
    Total time in seconds spent by the pool to process all items.
  
Use a pool of workers to concurrently process a sequence of items.
Use a pool of workers to concurrently process a sequence of items .
def Run(label, worker, args, items, stream=None):
  pool = multiprocessing.Pool(
      processes=args.processes, initializer=worker, initargs=(args,))
  time_started = pandas.Timestamp.utcnow()
  try:
    ProgressIndicator(label, pool.imap_unordered(_Worker, items), stream=stream)
    time_finished = pandas.Timestamp.utcnow()
  finally:
    pool.terminate()
    pool.join()
  return (time_finished - time_started).total_seconds()
def Run ( label , worker , args , items , stream = None ) : pool = multiprocessing . Pool ( processes = args . processes , initializer = worker , initargs = ( args , ) ) time_started = pandas . Timestamp . utcnow ( ) try : ProgressIndicator ( label , pool . imap_unordered ( _Worker , items ) , stream = stream ) time_finished = pandas . Timestamp . utcnow ( ) finally : pool . terminate ( ) pool . join ( ) return ( time_finished - time_started ) . total_seconds ( )
Use a pool of workers to concurrently process a sequence of items.
Use a pool of workers to concurrently process a sequence of items .
"""Use a pool of workers to concurrently process a sequence of items.

  Args:
    label: A string displayed by the progress indicator when the job starts.
    worker: A function with the worker implementation. See example above.
    args: An argparse.Namespace() object used to initialize the workers. The
        value of args.processes is the number of processes used by the pool.
    items: An iterable with items to process by the pool of workers.
    stream: A file-like object for the progress indicator output, defaults to
        sys.stdout.

  Returns:
    Total time in seconds spent by the pool to process all items.
  """ # Ensure resources (e.g. db connections from workers) are freed up.
Total time in seconds spent by the pool to process all items.
Total time in seconds spent by the pool to process all items .
label
A string displayed by the progress indicator when the job starts.
A string displayed by the progress indicator when the job starts .
worker
A function with the worker implementation. See example above.
A function with the worker implementation . See example above .
args
An argparse.Namespace() object used to initialize the workers. The
value of args.processes is the number of processes used by the pool.
An argparse . Namespace () object used to initialize the workers . The value of args . processes is the number of processes used by the pool .
items
An iterable with items to process by the pool of workers.
An iterable with items to process by the pool of workers .
stream
A file-like object for the progress indicator output, defaults to
sys.stdout.
A file - like object for the progress indicator output defaults to sys . stdout .