|
|
@ -1749,11 +1749,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() |
|
|
|
... |
|
|
|
thread.join() |
|
|
|
<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() |
|
|
|
lock.acquire() <span class="hljs-comment"># Waits for lock to be available.</span> |
|
|
|
... |
|
|
|
lock.release() |
|
|
|
</code></pre></div> |
|
|
@ -1767,7 +1768,7 @@ lock.release() |
|
|
|
<span class="hljs-keyword">with</span> ThreadPoolExecutor(max_workers=<span class="hljs-keyword">None</span>) <span class="hljs-keyword">as</span> executor: |
|
|
|
<iter> = 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> |
|
|
|
<iter> = 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> |
|
|
|
<Future> = executor.submit(<function>, <arg_1>, ...) |
|
|
|
<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> |
|
|
|