|
|
@ -1771,12 +1771,12 @@ db = connector.connect(host=<str>, user=<str>, password=<str>, |
|
|
|
<div><h3 id="thread">Thread</h3><pre><code class="python language-python hljs">thread = Thread(target=<function>, args=(<first_arg>, )) |
|
|
|
thread.start() |
|
|
|
... |
|
|
|
<bool> = thread.is_alive() <span class="hljs-comment"># Checks if thread has finished executing.</span> |
|
|
|
thread.join() <span class="hljs-comment"># Waits for thread to finish.</span> |
|
|
|
<bool> = thread.is_alive() <span class="hljs-comment"># Checks if thread has finished executing.</span> |
|
|
|
thread.join() <span class="hljs-comment"># Waits for thread to finish.</span> |
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
<div><h3 id="lock">Lock</h3><pre><code class="python language-python hljs">lock = RLock() |
|
|
|
lock.acquire() <span class="hljs-comment"># Waits for lock to be available.</span> |
|
|
|
lock.acquire() <span class="hljs-comment"># Waits for lock to be available.</span> |
|
|
|
... |
|
|
|
lock.release() |
|
|
|
</code></pre></div> |
|
|
@ -1793,18 +1793,18 @@ lock.release() |
|
|
|
<Future> = executor.submit(<function> [, <arg_1>, ...]) |
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
<pre><code class="python language-python hljs"><bool> = <Future>.done() <span class="hljs-comment"># Checks if thread has finished executing.</span> |
|
|
|
<obj> = <Future>.result() <span class="hljs-comment"># Waits for thread to finish and returns result.</span> |
|
|
|
<pre><code class="python language-python hljs"><bool> = <Future>.done() <span class="hljs-comment"># Checks if thread has finished executing.</span> |
|
|
|
<obj> = <Future>.result() <span class="hljs-comment"># Waits for thread to finish and returns result.</span> |
|
|
|
</code></pre> |
|
|
|
<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 |
|
|
|
<Queue> = Queue(maxsize=<span class="hljs-number">0</span>) |
|
|
|
</code></pre></div> |
|
|
|
|
|
|
|
|
|
|
|
<pre><code class="python language-python hljs"><Queue>.put(<el>) <span class="hljs-comment"># Blocks until queue stops being full.</span> |
|
|
|
<Queue>.put_nowait(<el>) <span class="hljs-comment"># Raises queue.Full exception if full.</span> |
|
|
|
<el> = <Queue>.get() <span class="hljs-comment"># Blocks until queue stops being empty.</span> |
|
|
|
<el> = <Queue>.get_nowait() <span class="hljs-comment"># Raises _queue.Empty exception if empty.</span> |
|
|
|
<pre><code class="python language-python hljs"><Queue>.put(<el>) <span class="hljs-comment"># Blocks until queue stops being full.</span> |
|
|
|
<Queue>.put_nowait(<el>) <span class="hljs-comment"># Raises queue.Full exception if full.</span> |
|
|
|
<el> = <Queue>.get() <span class="hljs-comment"># Blocks until queue stops being empty.</span> |
|
|
|
<el> = <Queue>.get_nowait() <span class="hljs-comment"># Raises _queue.Empty exception if empty.</span> |
|
|
|
</code></pre> |
|
|
|
<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 |
|
|
|
<span class="hljs-keyword">from</span> operator <span class="hljs-keyword">import</span> eq, ne, lt, le, gt, ge |
|
|
|
xxxxxxxxxx