blob: bb653d32ca8df5025d1a2fa72de911db7ef9fb5b [file] [log] [blame]
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./">
<head>
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>apache_beam.transforms.async_dofn module &mdash; Apache Beam 2.68.0 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=b86133f3" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=2388e03a"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="apache_beam.transforms.combinefn_lifecycle_pipeline module" href="apache_beam.transforms.combinefn_lifecycle_pipeline.html" />
<link rel="prev" title="apache_beam.transforms.xlang.io module" href="apache_beam.transforms.xlang.io.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home">
Apache Beam
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="apache_beam.coders.html">apache_beam.coders package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.dataframe.html">apache_beam.dataframe package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.io.html">apache_beam.io package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.metrics.html">apache_beam.metrics package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.ml.html">apache_beam.ml package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.options.html">apache_beam.options package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.portability.html">apache_beam.portability package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.runners.html">apache_beam.runners package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.testing.html">apache_beam.testing package</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="apache_beam.transforms.html">apache_beam.transforms package</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="apache_beam.transforms.html#subpackages">Subpackages</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="apache_beam.transforms.html#submodules">Submodules</a><ul class="current">
<li class="toctree-l3 current"><a class="current reference internal" href="#">apache_beam.transforms.async_dofn module</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#apache_beam.transforms.async_dofn.AsyncWrapper"><code class="docutils literal notranslate"><span class="pre">AsyncWrapper</span></code></a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.combinefn_lifecycle_pipeline.html">apache_beam.transforms.combinefn_lifecycle_pipeline module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.combiners.html">apache_beam.transforms.combiners module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.core.html">apache_beam.transforms.core module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.create_source.html">apache_beam.transforms.create_source module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.deduplicate.html">apache_beam.transforms.deduplicate module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.display.html">apache_beam.transforms.display module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.enrichment.html">apache_beam.transforms.enrichment module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.environments.html">apache_beam.transforms.environments module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.error_handling.html">apache_beam.transforms.error_handling module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.external.html">apache_beam.transforms.external module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.external_java.html">apache_beam.transforms.external_java module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.external_transform_provider.html">apache_beam.transforms.external_transform_provider module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.fully_qualified_named_transform.html">apache_beam.transforms.fully_qualified_named_transform module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.managed.html">apache_beam.transforms.managed module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.periodicsequence.html">apache_beam.transforms.periodicsequence module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.ptransform.html">apache_beam.transforms.ptransform module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.resources.html">apache_beam.transforms.resources module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.sideinputs.html">apache_beam.transforms.sideinputs module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.sql.html">apache_beam.transforms.sql module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.stats.html">apache_beam.transforms.stats module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.timeutil.html">apache_beam.transforms.timeutil module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.trigger.html">apache_beam.transforms.trigger module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.userstate.html">apache_beam.transforms.userstate module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.util.html">apache_beam.transforms.util module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.transforms.window.html">apache_beam.transforms.window module</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.typehints.html">apache_beam.typehints package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.utils.html">apache_beam.utils package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.yaml.html">apache_beam.yaml package</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.error.html">apache_beam.error module</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.pipeline.html">apache_beam.pipeline module</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.pvalue.html">apache_beam.pvalue module</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Apache Beam</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="apache_beam.transforms.html">apache_beam.transforms package</a></li>
<li class="breadcrumb-item active">apache_beam.transforms.async_dofn module</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/apache_beam.transforms.async_dofn.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="module-apache_beam.transforms.async_dofn">
<span id="apache-beam-transforms-async-dofn-module"></span><h1>apache_beam.transforms.async_dofn module<a class="headerlink" href="#module-apache_beam.transforms.async_dofn" title="Link to this heading"></a></h1>
<dl class="py class">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">apache_beam.transforms.async_dofn.</span></span><span class="sig-name descname"><span class="pre">AsyncWrapper</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sync_fn</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">parallelism</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">callback_frequency</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_items_to_buffer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">max_wait_time</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">120</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/transforms/async_dofn.html#AsyncWrapper"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper" title="Link to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="apache_beam.transforms.core.html#apache_beam.transforms.core.DoFn" title="apache_beam.transforms.core.DoFn"><code class="xref py py-class docutils literal notranslate"><span class="pre">DoFn</span></code></a></p>
<p>Class that wraps a dofn and converts it from one which process elements
synchronously to one which processes them asynchronously.</p>
<p>For synchronous dofns the default settings mean that many (100s) of elements
will be processed in parallel and that processing an element will block all
other work on that key. In addition runners are optimized for latencies less
than a few seconds and longer operations can result in high retry rates. Async
should be considered when the default parallelism is not correct and/or items
are expected to take longer than a few seconds to process.</p>
<p>Wraps the sync_fn to create an asynchronous version.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>sync_fn</strong> – The dofn to wrap. Must take (K, V) as input.</p></li>
<li><p><strong>parallelism</strong> – The maximum number of elements to process in parallel per
worker for this dofn. By default this is set to 1 as the most common
case for async dofns are heavy CPU or GPU dofns where the dofn requires
the a signficant fraction of the CPU/GPU.</p></li>
<li><p><strong>callback_frequency</strong> – The frequency with which the runner will check for
elements to commit. A short callback frequency will mean items are
commited shortly after processing but cause additional work for the
worker. A large callback frequency will result in slower commits but
less busy work. The default of 5s will result in a maximum added
latency of 5s while requiring relatively few resources. If your
messages take significantly longer than 5s to process it is recommended
to raise this.</p></li>
<li><p><strong>max_items_to_buffer</strong> – We should ideally buffer enough to always be busy but
not so much that the worker ooms. By default will be 2x the parallelism
which should be good for most pipelines.</p></li>
<li><p><strong>max_wait_time</strong> – The maximum amount of time an item should wait to be added
to the buffer. Used for testing to ensure timeouts are met.</p></li>
</ul>
</dd>
</dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.TIMER">
<span class="sig-name descname"><span class="pre">TIMER</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">TimerSpec(ts-timer)</span></em><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.TIMER" title="Link to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.TIMER_SET">
<span class="sig-name descname"><span class="pre">TIMER_SET</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">ReadModifyWriteStateSpec(timer_set)</span></em><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.TIMER_SET" title="Link to this definition"></a></dt>
<dd></dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.TO_PROCESS">
<span class="sig-name descname"><span class="pre">TO_PROCESS</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">BagStateSpec(to_process)</span></em><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.TO_PROCESS" title="Link to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.initialize_pool">
<em class="property"><span class="pre">static</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">initialize_pool</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">parallelism</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/transforms/async_dofn.html#AsyncWrapper.initialize_pool"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.initialize_pool" title="Link to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.reset_state">
<em class="property"><span class="pre">static</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">reset_state</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/transforms/async_dofn.html#AsyncWrapper.reset_state"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.reset_state" title="Link to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.setup">
<span class="sig-name descname"><span class="pre">setup</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/transforms/async_dofn.html#AsyncWrapper.setup"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.setup" title="Link to this definition"></a></dt>
<dd><p>Forwards to the wrapped dofn’s setup method.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.teardown">
<span class="sig-name descname"><span class="pre">teardown</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/transforms/async_dofn.html#AsyncWrapper.teardown"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.teardown" title="Link to this definition"></a></dt>
<dd><p>Forwards to the wrapped dofn’s teardown method.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.sync_fn_process">
<span class="sig-name descname"><span class="pre">sync_fn_process</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">element</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/transforms/async_dofn.html#AsyncWrapper.sync_fn_process"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.sync_fn_process" title="Link to this definition"></a></dt>
<dd><p>Makes the call to the wrapped dofn’s start_bundle, process</p>
<p>methods. It will then combine the results into a single generator.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>element</strong> – The element to process.</p></li>
<li><p><strong>*args</strong> – Any additional arguments to pass to the wrapped dofn’s process
method. Will be the same args that the async wrapper is called with.</p></li>
<li><p><strong>**kwargs</strong> – Any additional keyword arguments to pass to the wrapped dofn’s
process method. Will be the same kwargs that the async wrapper is
called with.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A generator of elements produced by the input element.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.decrement_items_in_buffer">
<span class="sig-name descname"><span class="pre">decrement_items_in_buffer</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">future</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/transforms/async_dofn.html#AsyncWrapper.decrement_items_in_buffer"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.decrement_items_in_buffer" title="Link to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.schedule_if_room">
<span class="sig-name descname"><span class="pre">schedule_if_room</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">element</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ignore_buffer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/transforms/async_dofn.html#AsyncWrapper.schedule_if_room"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.schedule_if_room" title="Link to this definition"></a></dt>
<dd><p>Schedules an item to be processed asynchronously if there is room.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>element</strong> – The element to process.</p></li>
<li><p><strong>ignore_buffer</strong> – If true will ignore the buffer limit and schedule the item
regardless of the buffer size. Used when an item needs to skip to the
front such as retries.</p></li>
<li><p><strong>*args</strong> – arguments that the wrapped dofn requires.</p></li>
<li><p><strong>**kwargs</strong> – keyword arguments that the wrapped dofn requires.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>True if the item was scheduled False otherwise.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.schedule_item">
<span class="sig-name descname"><span class="pre">schedule_item</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">element</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ignore_buffer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/transforms/async_dofn.html#AsyncWrapper.schedule_item"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.schedule_item" title="Link to this definition"></a></dt>
<dd><p>Schedules an item to be processed asynchronously.</p>
<p>If the queue is full will block until room opens up.</p>
<p>After calling AsyncWrapper will hold a future pointing to the
result of this processing</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>element</strong> – The element to process.</p></li>
<li><p><strong>ignore_buffer</strong> – If true will ignore the buffer limit and schedule the item
regardless of the buffer size. Used when an item needs to skip to the
front such as retries.</p></li>
<li><p><strong>*args</strong> – arguments that the wrapped dofn requires.</p></li>
<li><p><strong>**kwargs</strong> – keyword arguments that the wrapped dofn requires.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.next_time_to_fire">
<span class="sig-name descname"><span class="pre">next_time_to_fire</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/transforms/async_dofn.html#AsyncWrapper.next_time_to_fire"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.next_time_to_fire" title="Link to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.accepting_items">
<span class="sig-name descname"><span class="pre">accepting_items</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/transforms/async_dofn.html#AsyncWrapper.accepting_items"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.accepting_items" title="Link to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.is_empty">
<span class="sig-name descname"><span class="pre">is_empty</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/transforms/async_dofn.html#AsyncWrapper.is_empty"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.is_empty" title="Link to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.process">
<span class="sig-name descname"><span class="pre">process</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">element</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">TimerParam(ts</span> <span class="pre">-</span> <span class="pre">timer)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">to_process</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">StateParam(to_process)</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><span class="n"><span class="pre">args</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/transforms/async_dofn.html#AsyncWrapper.process"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.process" title="Link to this definition"></a></dt>
<dd><p>Add the elements to the list of items to be processed asynchronously.</p>
<p>Performs additional bookkeeping to maintain exactly once and set timers to
commit item after it has finished processing.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>element</strong> – The element to process.</p></li>
<li><p><strong>timer</strong> – Callback timer that will commit elements.</p></li>
<li><p><strong>to_process</strong> – State that keeps track of queued items for exactly once.</p></li>
<li><p><strong>*args</strong> – arguments that the wrapped dofn requires.</p></li>
<li><p><strong>**kwargs</strong> – keyword arguments that the wrapped dofn requires.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>An empty list. The elements will be output asynchronously.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.commit_finished_items">
<span class="sig-name descname"><span class="pre">commit_finished_items</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">to_process</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">StateParam(to_process)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">TimerParam(ts</span> <span class="pre">-</span> <span class="pre">timer)</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/transforms/async_dofn.html#AsyncWrapper.commit_finished_items"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.commit_finished_items" title="Link to this definition"></a></dt>
<dd><p>Commits finished items and synchronizes local state with runner state.</p>
<p>Note timer firings are per key while local state contains messages for all
keys. Only messages for the given key will be output/cleaned up.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>to_process</strong> – State that keeps track of queued messagees for this key.</p></li>
<li><p><strong>timer</strong> – Timer that initiated this commit and can be reset if not all items
have finished..</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A list of elements that have finished processing for this key.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="apache_beam.transforms.async_dofn.AsyncWrapper.timer_callback">
<span class="sig-name descname"><span class="pre">timer_callback</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">to_process</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">StateParam(to_process)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">timer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">TimerParam(ts</span> <span class="pre">-</span> <span class="pre">timer)</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/transforms/async_dofn.html#AsyncWrapper.timer_callback"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apache_beam.transforms.async_dofn.AsyncWrapper.timer_callback" title="Link to this definition"></a></dt>
<dd><p>Helper method to commit finished items in response to timer firing.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>to_process</strong> – State that keeps track of queued items for exactly once.</p></li>
<li><p><strong>timer</strong> – Timer that initiated this commit and can be reset if not all items
have finished.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A generator of elements that have finished processing for this key.</p>
</dd>
</dl>
</dd></dl>
</dd></dl>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="apache_beam.transforms.xlang.io.html" class="btn btn-neutral float-left" title="apache_beam.transforms.xlang.io module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="apache_beam.transforms.combinefn_lifecycle_pipeline.html" class="btn btn-neutral float-right" title="apache_beam.transforms.combinefn_lifecycle_pipeline module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright %Y, Apache Beam.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>