|
1771 | 1771 | <div><h3 id="thread">Thread</h3><pre><code class="python language-python hljs">thread = Thread(target=<function>, args=(<first_arg>, ))
|
1772 | 1772 | thread.start()
|
1773 | 1773 | ...
|
1774 |
| -<bool> = 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 | +<bool> = 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> |
1776 | 1776 | </code></pre></div>
|
1777 | 1777 |
|
1778 | 1778 | <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> |
1780 | 1780 | ...
|
1781 | 1781 | lock.release()
|
1782 | 1782 | </code></pre></div>
|
|
1793 | 1793 | <Future> = executor.submit(<function> [, <arg_1>, ...])
|
1794 | 1794 | </code></pre></div>
|
1795 | 1795 |
|
1796 |
| -<pre><code class="python language-python hljs"><bool> = <Future>.done() <span class="hljs-comment"># Checks if thread has finished executing.</span> |
1797 |
| -<obj> = <Future>.result() <span class="hljs-comment"># Waits for thread to finish and returns result.</span> |
| 1796 | +<pre><code class="python language-python hljs"><bool> = <Future>.done() <span class="hljs-comment"># Checks if thread has finished executing.</span> |
| 1797 | +<obj> = <Future>.result() <span class="hljs-comment"># Waits for thread to finish and returns result.</span> |
1798 | 1798 | </code></pre>
|
1799 | 1799 | <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
|
1800 | 1800 | <Queue> = Queue(maxsize=<span class="hljs-number">0</span>)
|
1801 | 1801 | </code></pre></div>
|
1802 | 1802 |
|
1803 | 1803 |
|
1804 |
| -<pre><code class="python language-python hljs"><Queue>.put(<el>) <span class="hljs-comment"># Blocks until queue stops being full.</span> |
1805 |
| -<Queue>.put_nowait(<el>) <span class="hljs-comment"># Raises queue.Full exception if full.</span> |
1806 |
| -<el> = <Queue>.get() <span class="hljs-comment"># Blocks until queue stops being empty.</span> |
1807 |
| -<el> = <Queue>.get_nowait() <span class="hljs-comment"># Raises _queue.Empty exception if empty.</span> |
| 1804 | +<pre><code class="python language-python hljs"><Queue>.put(<el>) <span class="hljs-comment"># Blocks until queue stops being full.</span> |
| 1805 | +<Queue>.put_nowait(<el>) <span class="hljs-comment"># Raises queue.Full exception if full.</span> |
| 1806 | +<el> = <Queue>.get() <span class="hljs-comment"># Blocks until queue stops being empty.</span> |
| 1807 | +<el> = <Queue>.get_nowait() <span class="hljs-comment"># Raises _queue.Empty exception if empty.</span> |
1808 | 1808 | </code></pre>
|
1809 | 1809 | <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
|
1810 | 1810 | <span class="hljs-keyword">from</span> operator <span class="hljs-keyword">import</span> eq, ne, lt, le, gt, ge
|
|
0 commit comments