Skip to content

Commit ec487e3

Browse files
committed
Threading
1 parent 621d85b commit ec487e3

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,14 +2011,14 @@ from threading import Thread, RLock
20112011
thread = Thread(target=<function>, args=(<first_arg>, ))
20122012
thread.start()
20132013
...
2014-
<bool> = thread.is_alive() # Checks if thread has finished executing.
2015-
thread.join() # Waits for thread to finish.
2014+
<bool> = thread.is_alive() # Checks if thread has finished executing.
2015+
thread.join() # Waits for thread to finish.
20162016
```
20172017

20182018
### Lock
20192019
```python
20202020
lock = RLock()
2021-
lock.acquire() # Waits for lock to be available.
2021+
lock.acquire() # Waits for lock to be available.
20222022
...
20232023
lock.release()
20242024
```
@@ -2040,8 +2040,8 @@ with ThreadPoolExecutor(max_workers=None) as executor:
20402040
```
20412041

20422042
```python
2043-
<bool> = <Future>.done() # Checks if thread has finished executing.
2044-
<obj> = <Future>.result() # Waits for thread to finish and returns result.
2043+
<bool> = <Future>.done() # Checks if thread has finished executing.
2044+
<obj> = <Future>.result() # Waits for thread to finish and returns result.
20452045
```
20462046

20472047
### Queue
@@ -2052,10 +2052,10 @@ from queue import Queue
20522052
```
20532053

20542054
```python
2055-
<Queue>.put(<el>) # Blocks until queue stops being full.
2056-
<Queue>.put_nowait(<el>) # Raises queue.Full exception if full.
2057-
<el> = <Queue>.get() # Blocks until queue stops being empty.
2058-
<el> = <Queue>.get_nowait() # Raises _queue.Empty exception if empty.
2055+
<Queue>.put(<el>) # Blocks until queue stops being full.
2056+
<Queue>.put_nowait(<el>) # Raises queue.Full exception if full.
2057+
<el> = <Queue>.get() # Blocks until queue stops being empty.
2058+
<el> = <Queue>.get_nowait() # Raises _queue.Empty exception if empty.
20592059
```
20602060

20612061

index.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1771,12 +1771,12 @@
17711771
<div><h3 id="thread">Thread</h3><pre><code class="python language-python hljs">thread = Thread(target=&lt;function&gt;, args=(&lt;first_arg&gt;, ))
17721772
thread.start()
17731773
...
1774-
&lt;bool&gt; = thread.is_alive() <span class="hljs-comment"># Checks if thread has finished executing.</span>
1775-
thread.join() <span class="hljs-comment"># Waits for thread to finish.</span>
1774+
&lt;bool&gt; = thread.is_alive() <span class="hljs-comment"># Checks if thread has finished executing.</span>
1775+
thread.join() <span class="hljs-comment"># Waits for thread to finish.</span>
17761776
</code></pre></div>
17771777

17781778
<div><h3 id="lock">Lock</h3><pre><code class="python language-python hljs">lock = RLock()
1779-
lock.acquire() <span class="hljs-comment"># Waits for lock to be available.</span>
1779+
lock.acquire() <span class="hljs-comment"># Waits for lock to be available.</span>
17801780
...
17811781
lock.release()
17821782
</code></pre></div>
@@ -1793,18 +1793,18 @@
17931793
&lt;Future&gt; = executor.submit(&lt;function&gt; [, &lt;arg_1&gt;, ...])
17941794
</code></pre></div>
17951795

1796-
<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>
1797-
&lt;obj&gt; = &lt;Future&gt;.result() <span class="hljs-comment"># Waits for thread to finish and returns result.</span>
1796+
<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>
1797+
&lt;obj&gt; = &lt;Future&gt;.result() <span class="hljs-comment"># Waits for thread to finish and returns result.</span>
17981798
</code></pre>
17991799
<div><h3 id="queue">Queue</h3><p><strong>A thread-safe FIFO queue. For LIFO queue use LifoQueue.</strong></p><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> queue <span class="hljs-keyword">import</span> Queue
18001800
&lt;Queue&gt; = Queue(maxsize=<span class="hljs-number">0</span>)
18011801
</code></pre></div>
18021802

18031803

1804-
<pre><code class="python language-python hljs">&lt;Queue&gt;.put(&lt;el&gt;) <span class="hljs-comment"># Blocks until queue stops being full.</span>
1805-
&lt;Queue&gt;.put_nowait(&lt;el&gt;) <span class="hljs-comment"># Raises queue.Full exception if full.</span>
1806-
&lt;el&gt; = &lt;Queue&gt;.get() <span class="hljs-comment"># Blocks until queue stops being empty.</span>
1807-
&lt;el&gt; = &lt;Queue&gt;.get_nowait() <span class="hljs-comment"># Raises _queue.Empty exception if empty.</span>
1804+
<pre><code class="python language-python hljs">&lt;Queue&gt;.put(&lt;el&gt;) <span class="hljs-comment"># Blocks until queue stops being full.</span>
1805+
&lt;Queue&gt;.put_nowait(&lt;el&gt;) <span class="hljs-comment"># Raises queue.Full exception if full.</span>
1806+
&lt;el&gt; = &lt;Queue&gt;.get() <span class="hljs-comment"># Blocks until queue stops being empty.</span>
1807+
&lt;el&gt; = &lt;Queue&gt;.get_nowait() <span class="hljs-comment"># Raises _queue.Empty exception if empty.</span>
18081808
</code></pre>
18091809
<div><h2 id="operator"><a href="#operator" name="operator">#</a>Operator</h2><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> operator <span class="hljs-keyword">import</span> add, sub, mul, truediv, floordiv, mod, pow, neg, abs
18101810
<span class="hljs-keyword">from</span> operator <span class="hljs-keyword">import</span> eq, ne, lt, le, gt, ge

0 commit comments

Comments
 (0)