• Home
  • Raw
  • Download

Lines Matching +full:no +full:- +full:threads

1 :mod:`threading` --- Thread-based parallelism
5 :synopsis: Thread-based parallelism.
9 --------------
11 This module constructs higher-level threading interfaces on top of the lower
24 .. impl-detail::
28 can execute Python code at once (even though certain performance-oriented
31 resources of multi-core machines, you are advised to use
34 multiple I/O-bound tasks simultaneously.
80 exception is no longer needed.
102 integer. Its value has no direct meaning; it is intended as a magic cookie
103 to be used e.g. to index a dictionary of thread-specific data. Thread
113 This is a non-negative integer.
114 Its value may be used to uniquely identify this particular thread system-wide
125 includes daemonic threads and dummy thread objects created by
126 :func:`current_thread`. It excludes terminated threads and threads
144 Set a trace function for all threads started from the :mod:`threading` module.
164 Set a profile function for all threads started from the :mod:`threading` module.
180 Return the thread stack size used when creating new threads. The optional
182 threads, and must be 0 (use platform or configured default) or a positive
191 memory page size - platform documentation should be referred to for more
195 .. availability:: Windows, systems with POSIX threads.
216 subset of the behavior of Java's Thread class; currently, there are no
217 priorities, no thread groups, and threads cannot be destroyed, stopped,
219 when implemented, are mapped to module-level functions.
224 Thread-Local Data
225 -----------------
227 Thread-local data is data whose values are thread specific. To manage
228 thread-local data, just create an instance of :class:`local` (or a
234 The instance's values will be different for separate threads.
239 A class that represents thread-local data.
245 .. _thread-objects:
248 --------------
253 method in a subclass. No other methods (except for the constructor) should be
262 stops being alive when its :meth:`~Thread.run` method terminates -- either
266 Other threads can call a thread's :meth:`~Thread.join` method. This blocks
278 that the entire Python program exits when only daemon threads are left. The
284 Daemon threads are abruptly stopped at shutdown. Their resources (such
286 If you want your threads to stop gracefully, make them non-daemonic and
293 thread objects corresponding to "alien threads", which are threads of control
297 since it is impossible to detect the termination of alien threads.
313 of the form "Thread-*N*" where *N* is a small decimal number,
314 or "Thread-*N* (target)" where "target" is ``target.__name__`` if the
359 the thread whose :meth:`~Thread.join` method is called terminates -- either
360 normally or through an unhandled exception -- or until the optional
367 decide whether a timeout happened -- if the thread is still alive, the
382 A string used for identification purposes only. It has no semantics.
383 Multiple threads may be given the same name. The initial name is set by
405 This is a non-negative integer, or ``None`` if the thread has not
408 system-wide (until the thread terminates, after which the value
414 system-wide) from the time the thread is created until the thread
427 module function :func:`.enumerate` returns a list of all alive threads.
435 therefore all threads created in the main thread default to
438 The entire Python program exits when no alive non-daemon threads are left.
449 .. _lock-objects:
452 ------------
470 Locks also support the :ref:`context management protocol <with-locks>`.
474 call resets the state to unlocked; which one of the waiting threads proceeds
491 .. method:: acquire(blocking=True, timeout=-1)
493 Acquire a lock, blocking or non-blocking.
502 When invoked with the floating-point *timeout* argument set to a positive
504 and as long as the lock cannot be acquired. A *timeout* argument of ``-1``
524 When the lock is locked, reset it to unlocked, and return. If any other threads
530 There is no return value.
538 .. _rlock-objects:
541 -------------
547 no thread owns it.
556 Reentrant locks also support the :ref:`context management protocol <with-locks>`.
571 .. method:: acquire(blocking=True, timeout=-1)
573 Acquire a lock, blocking or non-blocking.
581 There is no return value in this case.
590 When invoked with the floating-point *timeout* argument set to a positive
603 threads are blocked waiting for the lock to become unlocked, allow exactly one
611 There is no return value.
614 .. _condition-objects:
617 -----------------
624 A condition variable obeys the :ref:`context management protocol <with-locks>`:
634 re-acquires the lock and returns. It is also possible to specify a timeout.
636 The :meth:`~Condition.notify` method wakes up one of the threads waiting for
638 method wakes up all threads waiting for the condition variable.
641 don't release the lock; this means that the thread or threads awakened will
647 synchronize access to some shared state; threads that are interested in a
649 see the desired state, while threads that modify the state call
653 producer-consumer situation with unlimited buffer capacity::
669 no longer hold true. This is inherent to multi-threaded programming. The
680 waiting threads. E.g. in a typical producer-consumer situation, adding one
687 allows one or more threads to wait until they are notified by another thread.
704 the underlying lock; there is no return value.
715 occurs. Once awakened or timed out, it re-acquires the lock and returns.
753 held when called and is re-acquired on return. The predicate is evaluated
764 This method wakes up at most *n* of the threads waiting for the condition
765 variable; it is a no-op if no threads are waiting.
767 The current implementation wakes up exactly *n* threads, if at least *n*
768 threads are waiting. However, it's not safe to rely on this behavior.
770 *n* threads.
778 Wake up all threads waiting on this condition. This method acts like
779 :meth:`notify`, but wakes up all waiting threads instead of one. If the
786 .. _semaphore-objects:
789 -----------------
802 Semaphores also support the :ref:`context management protocol <with-locks>`.
832 order in which threads are awoken should not be relied on.
848 was zero on entry and other threads are waiting for it to become larger
849 than zero again, wake up *n* of those threads.
852 Added the *n* parameter to release multiple waiting threads at once.
867 .. _semaphore-examples:
874 you should use a bounded semaphore. Before spawning any worker threads, your
881 Once spawned, worker threads call the semaphore's acquire and release methods
895 .. _event-objects:
898 -------------
900 This is one of the simplest mechanisms for communication between threads: one
901 thread signals an event and other threads wait for it.
926 Set the internal flag to true. All threads waiting for it to become true
927 are awakened. Threads that call :meth:`wait` once the flag is true will
932 Reset the internal flag to false. Subsequently, threads calling
955 .. _timer-objects:
958 -------------
961 of time has passed --- a timer. :class:`Timer` is a subclass of :class:`Thread`
962 and as such also functions as an example of creating custom threads.
964 Timers are started, as with threads, by calling their :meth:`~Timer.start`
996 ---------------
1001 of threads that need to wait for each other. Each of the threads tries to pass
1003 all of the threads have made their :meth:`~Barrier.wait` calls. At this point,
1004 the threads are released simultaneously.
1006 The barrier can be reused any number of times for the same number of threads.
1028 Create a barrier object for *parties* number of threads. An *action*, when
1029 provided, is a callable to be called by one of the threads when they are
1035 Pass the barrier. When all the threads party to the barrier have called
1040 The return value is an integer in the range 0 to *parties* -- 1, different
1049 If an *action* was provided to the constructor, one of the threads will
1060 Return the barrier to the default, empty state. Any threads waiting on it
1064 synchronization if there are other threads whose state is unknown. If a
1071 this for example if one of the threads needs to abort, to avoid deadlocking the
1075 *timeout* value to automatically guard against one of the threads going
1080 The number of threads required to pass the barrier.
1084 The number of threads currently waiting in the barrier.
1097 .. _with-locks:
1100 -------------------------------------------------------------------------