Browse Source

Threading

pull/46/head
Jure Šorn 5 years ago
parent
commit
55e10056e7
2 changed files with 2 additions and 2 deletions
  1. 2
      README.md
  2. 2
      index.html

2
README.md

@ -2030,7 +2030,7 @@ with lock:
... ...
``` ```
### Thread Pool
### Thread Pool Executor
```python ```python
from concurrent.futures import ThreadPoolExecutor from concurrent.futures import ThreadPoolExecutor
with ThreadPoolExecutor(max_workers=None) as executor: with ThreadPoolExecutor(max_workers=None) as executor:

2
index.html

@ -1786,7 +1786,7 @@ lock.release()
... ...
</code></pre></div> </code></pre></div>
<div><h3 id="threadpool">Thread Pool</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> concurrent.futures <span class="hljs-keyword">import</span> ThreadPoolExecutor
<div><h3 id="threadpoolexecutor">Thread Pool Executor</h3><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> concurrent.futures <span class="hljs-keyword">import</span> ThreadPoolExecutor
<span class="hljs-keyword">with</span> ThreadPoolExecutor(max_workers=<span class="hljs-keyword">None</span>) <span class="hljs-keyword">as</span> executor: <span class="hljs-keyword">with</span> ThreadPoolExecutor(max_workers=<span class="hljs-keyword">None</span>) <span class="hljs-keyword">as</span> executor:
&lt;iter&gt; = executor.map(<span class="hljs-keyword">lambda</span> x: x + <span class="hljs-number">1</span>, range(<span class="hljs-number">3</span>)) <span class="hljs-comment"># (1, 2, 3)</span> &lt;iter&gt; = executor.map(<span class="hljs-keyword">lambda</span> x: x + <span class="hljs-number">1</span>, range(<span class="hljs-number">3</span>)) <span class="hljs-comment"># (1, 2, 3)</span>
&lt;iter&gt; = executor.map(<span class="hljs-keyword">lambda</span> x, y: x + y, <span class="hljs-string">'abc'</span>, <span class="hljs-string">'123'</span>) <span class="hljs-comment"># ('a1', 'b2', 'c3')</span> &lt;iter&gt; = executor.map(<span class="hljs-keyword">lambda</span> x, y: x + y, <span class="hljs-string">'abc'</span>, <span class="hljs-string">'123'</span>) <span class="hljs-comment"># ('a1', 'b2', 'c3')</span>

Loading…
Cancel
Save