diff --git a/README.md b/README.md index 6abefb0..bf16cea 100644 --- a/README.md +++ b/README.md @@ -2100,7 +2100,7 @@ Threading --------- **CPython interpreter can only run a single thread at a time. Using multiple threads won't result in a faster execution, unless at least one of the threads contains an I/O operation.** ```python -from threading import Thread, Timer, RLock, Semaphore, Event, Barrier +from threading import Thread, RLock, Semaphore, Event, Barrier from concurrent.futures import ThreadPoolExecutor, as_completed ``` @@ -2113,7 +2113,6 @@ from concurrent.futures import ThreadPoolExecutor, as_completed ``` * **Use `'kwargs='` to pass keyword arguments to the function.** * **Use `'daemon=True'`, or the program will not be able to exit while the thread is alive.** -* **To delay thread execution use `'Timer(seconds, )'` instead of Thread().** ### Lock ```python @@ -2158,7 +2157,7 @@ with : # Enters the block by calling acq = .cancel() # Cancels or returns False if running/finished. = as_completed() # Next() waits for next completed Future. ``` -* **Map() and as\_completed() also accept 'timeout'. It causes futures.TimeoutError when next() is called. Map() times from original call and as_completed() from first call to next().** +* **Map() and as\_completed() also accept 'timeout'. It causes futures.TimeoutError when next() is called/blocking. Map() times from original call and as_completed() from first call to next(). As\_completed() fails if next() is called too late, even if thread finished on time.** * **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.** * **ProcessPoolExecutor provides true parallelism, but everything sent to/from workers must be [pickable](#pickle). Queues must be sent using executor's 'initargs' and 'initializer' parameters.** diff --git a/index.html b/index.html index 8390a84..cd21f57 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -1723,7 +1723,7 @@ CompletedProcess(args=['bc', 1) # Last element becomes first. <el> = <deque>.popleft() # Raises IndexError if deque is empty. -

#Threading

CPython interpreter can only run a single thread at a time. Using multiple threads won't result in a faster execution, unless at least one of the threads contains an I/O operation.

from threading import Thread, Timer, RLock, Semaphore, Event, Barrier
+

#Threading

CPython interpreter can only run a single thread at a time. Using multiple threads won't result in a faster execution, unless at least one of the threads contains an I/O operation.

from threading import Thread, RLock, Semaphore, Event, Barrier
 from concurrent.futures import ThreadPoolExecutor, as_completed
 
@@ -1737,7 +1737,6 @@ CompletedProcess(args=['bc', 'kwargs=<dict>'
to pass keyword arguments to the function.
  • Use 'daemon=True', or the program will not be able to exit while the thread is alive.
  • -
  • To delay thread execution use 'Timer(seconds, <func>)' instead of Thread().
  • Lock

    <lock> = RLock()                               # Lock that can only be released by acquirer.
     <lock>.acquire()                               # Waits for the lock to be available.
    @@ -1772,7 +1771,7 @@ CompletedProcess(args=['bc', # Next() waits for next completed Future.
     
      -
    • Map() and as_completed() also accept 'timeout'. It causes futures.TimeoutError when next() is called. Map() times from original call and as_completed() from first call to next().
    • +
    • Map() and as_completed() also accept 'timeout'. It causes futures.TimeoutError when next() is called/blocking. Map() times from original call and as_completed() from first call to next(). As_completed() fails if next() is called too late, even if thread finished on time.
    • 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.
    • ProcessPoolExecutor provides true parallelism, but everything sent to/from workers must be pickable. Queues must be sent using executor's 'initargs' and 'initializer' parameters.
    @@ -2933,7 +2932,7 @@ $ deactivate # Deactivates the activ