Skip to content

Commit 1649a43

Browse files
committed
Threading
1 parent 42f7b65 commit 1649a43

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ class Counter:
11731173
* **Enter() should lock the resources and optionally return an object.**
11741174
* **Exit() should release the resources.**
11751175
* **Any exception that happens inside the with block is passed to the exit() method.**
1176-
* **If it wishes to suppress the exception it must return a true value.**
1176+
* **If it wishes to suppress the exception it must return a true value.**
11771177
```python
11781178
class MyOpen:
11791179
def __init__(self, filename):
@@ -2078,10 +2078,10 @@ with lock:
20782078
### Thread Pool Executor
20792079
```python
20802080
from concurrent.futures import ThreadPoolExecutor
2081-
with ThreadPoolExecutor(max_workers=None) as executor:
2081+
with ThreadPoolExecutor(max_workers=None) as executor: # Does not exit until done.
20822082
<iter> = executor.map(lambda x: x + 1, range(3)) # (1, 2, 3)
20832083
<iter> = executor.map(lambda x, y: x + y, 'abc', '123') # ('a1', 'b2', 'c3')
2084-
<Future> = executor.submit(<function> [, <arg_1>, ...])
2084+
<Future> = executor.submit(<function> [, <arg_1>, ...]) # Also visible outside block.
20852085
```
20862086

20872087
#### Future:

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@
11191119
<li><strong>Enter() should lock the resources and optionally return an object.</strong></li>
11201120
<li><strong>Exit() should release the resources.</strong></li>
11211121
<li><strong>Any exception that happens inside the with block is passed to the exit() method.</strong></li>
1122-
<li><strong>If it wishes to suppress the exception it must return a true value.</strong> </li>
1122+
<li><strong>If it wishes to suppress the exception it must return a true value.</strong></li>
11231123
</ul><pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyOpen</span>:</span>
11241124
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self, filename)</span>:</span>
11251125
self.filename = filename
@@ -1832,10 +1832,10 @@
18321832
</code></pre></div>
18331833

18341834
<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
1835-
<span class="hljs-keyword">with</span> ThreadPoolExecutor(max_workers=<span class="hljs-keyword">None</span>) <span class="hljs-keyword">as</span> executor:
1835+
<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-comment"># Does not exit until done.</span>
18361836
&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>
18371837
&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>
1838-
&lt;Future&gt; = executor.submit(&lt;function&gt; [, &lt;arg_1&gt;, ...])
1838+
&lt;Future&gt; = executor.submit(&lt;function&gt; [, &lt;arg_1&gt;, ...]) <span class="hljs-comment"># Also visible outside block.</span>
18391839
</code></pre></div>
18401840

18411841
<div><h4 id="future">Future:</h4><pre><code class="python language-python hljs">&lt;bool&gt; = &lt;Future&gt;.done() <span class="hljs-comment"># Checks if thread has finished executing.</span>

0 commit comments

Comments
 (0)