From 180b1d52f41952ac16377672db8ee5ced3372bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Sun, 4 Jun 2023 15:16:32 +0200 Subject: [PATCH] Threading --- README.md | 10 +++++----- index.html | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index cc9d2b4..30596ec 100644 --- a/README.md +++ b/README.md @@ -2118,8 +2118,8 @@ from concurrent.futures import ThreadPoolExecutor, as_completed #### Or: ```python -with : # Enters the block by calling acquire(), - ... # and exits it with release(), even on error. +with : # Enters the block by calling acquire() and + ... # exits it with release(), even on error. ``` ### Semaphore, Event, Barrier @@ -2141,8 +2141,8 @@ with : # Enters the block by calling acq ### Thread Pool Executor ```python = ThreadPoolExecutor(max_workers=None) # Or: `with ThreadPoolExecutor() as : …` - = .map(, , ...) # A multithreaded non-lazy map(). Keeps order. - = .submit(, , ...) # Starts a thread and returns its Future object. + = .map(, , ...) # Multithreaded and non-lazy map(). Keeps order. + = .submit(, , ...) # Creates a thread and returns its Future object. .shutdown(wait=True) # Blocks until all threads finish executing. ``` @@ -2153,7 +2153,7 @@ with : # Enters the block by calling acq = as_completed() # Each Future is yielded as it completes. ``` * **Map() and as_completed() also accept 'timeout' argument that causes TimeoutError if result isn't available in 'timeout' seconds after next() is called.** -* **Exceptions that happen inside threads are raised when next() is called on map's iterator or when result() is called on a Future. It's exception() method returns exception or None.** +* **Exceptions that happen inside threads are raised when next() is called on map's iterator or when result() is called on a Future. Its exception() method returns exception or None.** * **An object with the same interface called ProcessPoolExecutor provides true parallelism by running a separate interpreter in each process. Arguments and results must be [pickable](#pickle).** diff --git a/index.html b/index.html index 1c39d24..bee409e 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -1752,8 +1752,8 @@ CompletedProcess(args=['bc', # Makes the lock available again. -

Or:

with <lock>:                                   # Enters the block by calling acquire(),
-    ...                                        # and exits it with release(), even on error.
+

Or:

with <lock>:                                   # Enters the block by calling acquire() and
+    ...                                        # exits it with release(), even on error.
 

Semaphore, Event, Barrier

<Semaphore> = Semaphore(value=1)               # Lock that can be acquired by 'value' threads.
@@ -1769,8 +1769,8 @@ CompletedProcess(args=['bc', Thread Pool Executor
<Exec> = ThreadPoolExecutor(max_workers=None)  # Or: `with ThreadPoolExecutor() as <name>: …`
-<iter> = <Exec>.map(<func>, <args_1>, ...)     # A multithreaded non-lazy map(). Keeps order.
-<Futr> = <Exec>.submit(<func>, <arg_1>, ...)   # Starts a thread and returns its Future object.
+<iter> = <Exec>.map(<func>, <args_1>, ...)     # Multithreaded and non-lazy map(). Keeps order.
+<Futr> = <Exec>.submit(<func>, <arg_1>, ...)   # Creates a thread and returns its Future object.
 <Exec>.shutdown(wait=True)                     # Blocks until all threads finish executing.
 
@@ -1781,7 +1781,7 @@ CompletedProcess(args=['bc', pickable.

#Operator

Module of functions that provide the functionality of operators.

import operator as op
@@ -2934,7 +2934,7 @@ $ pyinstaller script.py --add-data '<path>:.'