You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-15Lines changed: 15 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -2104,7 +2104,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
2104
2104
```
2105
2105
***Use `'kwargs=<dict>'` to pass keyword arguments to the function.**
2106
2106
***Use `'daemon=True'`, or the program will not be able to exit while the thread is alive.**
2107
-
***To delay thread execution use `'Timer(<float>, <func>)'` instead of Thread().**
2107
+
***To delay thread execution use `'Timer(seconds, <func>)'` instead of Thread().**
2108
2108
2109
2109
### Lock
2110
2110
```python
@@ -2137,16 +2137,16 @@ with <lock>: # Enters the block by calling acq
2137
2137
2138
2138
### Thread Pool Executor
2139
2139
```python
2140
-
<Exec>= ThreadPoolExecutor(max_workers=None) # Or: `with ThreadPoolExecutor() as <name>: …`
2140
+
<Exec>= ThreadPoolExecutor(max_workers=None) # Or: `with ThreadPoolExecutor() as <name>: ...`
2141
2141
<iter>=<Exec>.map(<func>, <args_1>, ...) # Multithreaded and non-lazy map(). Keeps order.
2142
2142
<Futr>=<Exec>.submit(<func>, <arg_1>, ...) # Creates a thread and returns its Future obj.
2143
-
<Exec>.shutdown(wait=True)# Blocks until all threads finish executing.
2143
+
<Exec>.shutdown() # Blocks until all threads finish executing.
2144
2144
```
2145
2145
2146
2146
```python
2147
2147
<bool>=<Future>.done() # Checks if the thread has finished executing.
2148
2148
<obj>=<Future>.result(timeout=None) # Waits for thread to finish and returns result.
2149
-
<bool>=<Future>.cancel() #Returns False if thread is already running.
2149
+
<bool>=<Future>.cancel() #Cancels or returns False if running/finished.
2150
2150
<iter>= as_completed(<coll_of_Futures>) # Each Future is yielded as it completes.
2151
2151
```
2152
2152
***Map() and as_completed() also accept 'timeout' argument that causes TimeoutError if result isn't available in 'timeout' seconds after next() is called.**
@@ -2159,13 +2159,13 @@ Operator
2159
2159
**Module of functions that provide the functionality of operators. Functions are ordered by operator precedence, starting with least binding.**
2160
2160
```python
2161
2161
import operator as op
2162
-
<bool>= op.not_(<obj>) # or, and (both missing), not
2163
-
<bool>= op.eq/ne/lt/le/gt/ge/contains/is_(<obj>, <obj>) # ==, !=, <, <=, >, >=, in, is
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'kwargs=<dict>'</span></code> to pass keyword arguments to the function.</strong></li>
1743
1743
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'daemon=True'</span></code>, or the program will not be able to exit while the thread is alive.</strong></li>
1744
-
<li><strong>To delay thread execution use <codeclass="python hljs"><spanclass="hljs-string">'Timer(<float>, <func>)'</span></code> instead of Thread().</strong></li>
1744
+
<li><strong>To delay thread execution use <codeclass="python hljs"><spanclass="hljs-string">'Timer(seconds, <func>)'</span></code> instead of Thread().</strong></li>
1745
1745
</ul>
1746
1746
<div><h3id="lock">Lock</h3><pre><codeclass="python language-python hljs"><lock> = RLock() <spanclass="hljs-comment"># Lock that can only be released by acquirer.</span>
1747
1747
<lock>.acquire() <spanclass="hljs-comment"># Waits for the lock to be available.</span>
<Futr> = <Exec>.submit(<func>, <arg_1>, ...) <spanclass="hljs-comment"># Creates a thread and returns its Future obj.</span>
1770
-
<Exec>.shutdown(wait=<spanclass="hljs-keyword">True</span>)<spanclass="hljs-comment"># Blocks until all threads finish executing.</span>
1770
+
<Exec>.shutdown() <spanclass="hljs-comment"># Blocks until all threads finish executing.</span>
1771
1771
</code></pre></div>
1772
1772
1773
1773
<pre><codeclass="python language-python hljs"><bool> = <Future>.done() <spanclass="hljs-comment"># Checks if the thread has finished executing.</span>
1774
1774
<obj> = <Future>.result(timeout=<spanclass="hljs-keyword">None</span>) <spanclass="hljs-comment"># Waits for thread to finish and returns result.</span>
1775
-
<bool> = <Future>.cancel() <spanclass="hljs-comment"># Returns False if thread is already running.</span>
1775
+
<bool> = <Future>.cancel() <spanclass="hljs-comment"># Cancels or returns False if running/finished.</span>
1776
1776
<iter> = as_completed(<coll_of_Futures>) <spanclass="hljs-comment"># Each Future is yielded as it completes.</span>
<li><strong>ProcessPoolExecutor provides true parallelism, but everything sent to/from workers must be <ahref="#pickle">pickable</a>. Queues must be sent using executor's 'initargs' and 'initializer' parameters.</strong></li>
1782
1782
</ul>
1783
1783
<div><h2id="operator"><ahref="#operator" name="operator">#</a>Operator</h2><p><strong>Module of functions that provide the functionality of operators. Functions are ordered by operator precedence, starting with least binding.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">import</span> operator <spanclass="hljs-keyword">as</span> op
1784
-
<bool> = op.not_(<obj>) <spanclass="hljs-comment"># or, and (both missing), not</span>
<div><h4id="addsnoisetoamonowavfile">Adds noise to a mono WAV file:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> random <spanclass="hljs-keyword">import</span> random
2392
+
<div><h4id="addsnoisetothemonowavfile">Adds noise to the mono WAV file:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> random <spanclass="hljs-keyword">import</span> random
<Surf> = <Font>.render(text, antialias, color) <spanclass="hljs-comment"># Background color can be specified at the end.</span>
2483
2483
</code></pre></div>
2484
2484
2485
-
<div><h3id="sound">Sound</h3><pre><codeclass="python language-python hljs"><Sound> = pg.mixer.Sound(<path/file/bytes>) <spanclass="hljs-comment"># Loads WAV file or array of signed shorts.</span>
2485
+
<div><h3id="sound">Sound</h3><pre><codeclass="python language-python hljs"><Sound> = pg.mixer.Sound(<path/file/bytes>) <spanclass="hljs-comment"># WAV file or bytes/array of signed shorts.</span>
2486
2486
<Sound>.play/stop() <spanclass="hljs-comment"># Also <Sound>.set_volume(<float>).</span>
0 commit comments