Lines Matching +full:set +full:- +full:blocking
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
20 to push tasks to a background thread without blocking execution of the
23 :mod:`queue` provides a thread-safe interface for exchanging data between
36 .. impl-detail::
40 can execute Python code at once (even though certain performance-oriented
43 resources of multi-core machines, you are advised to use
46 multiple I/O-bound tasks simultaneously.
48 .. include:: ../includes/wasm-notavail.rst
95 Storing *thread* using a custom hook can resurrect it if it is set to an
116 to be used e.g. to index a dictionary of thread-specific data. Thread
126 This is a non-negative integer.
127 Its value may be used to uniquely identify this particular thread system-wide
157 Set a trace function for all threads started from the :mod:`threading` module.
168 Get the trace function as set by :func:`settrace`.
177 Set a profile function for all threads started from the :mod:`threading` module.
186 Get the profiler function as set by :func:`setprofile`.
204 memory page size - platform documentation should be referred to for more
217 The maximum value allowed for the *timeout* parameter of blocking functions
234 when implemented, are mapped to module-level functions.
239 Thread-Local Data
240 -----------------
242 Thread-local data is data whose values are thread specific. To manage
243 thread-local data, just create an instance of :class:`local` (or a
254 A class that represents thread-local data.
260 .. _thread-objects:
263 --------------
277 stops being alive when its :meth:`~Thread.run` method terminates -- either
294 initial value is inherited from the creating thread. The flag can be set
301 If you want your threads to stop gracefully, make them non-daemonic and
311 daemonic, and cannot be :ref:`joined <meth-thread-join>`. They are never deleted,
328 of the form "Thread-*N*" where *N* is a small decimal number,
329 or "Thread-*N* (target)" where "target" is ``target.__name__`` if the
384 .. _meth-thread-join:
389 the thread whose :meth:`~Thread.join` method is called terminates -- either
390 normally or through an unhandled exception -- or until the optional
397 decide whether a timeout happened -- if the thread is still alive, the
413 Multiple threads may be given the same name. The initial name is set by
435 This is a non-negative integer, or ``None`` if the thread has not
438 system-wide (until the thread terminates, after which the value
444 system-wide) from the time the thread is created until the thread
462 or not (``False``). This must be set before :meth:`~Thread.start` is called,
468 The entire Python program exits when no alive non-daemon threads are left.
479 .. _lock-objects:
482 ------------
500 Locks also support the :ref:`context management protocol <with-locks>`.
521 .. method:: acquire(blocking=True, timeout=-1)
523 Acquire a lock, blocking or non-blocking.
525 When invoked with the *blocking* argument set to ``True`` (the default),
526 block until the lock is unlocked, then set it to locked and return ``True``.
528 When invoked with the *blocking* argument set to ``False``, do not block.
529 If a call with *blocking* set to ``True`` would block, return ``False``
530 immediately; otherwise, set the lock to locked and return ``True``.
532 When invoked with the floating-point *timeout* argument set to a positive
534 and as long as the lock cannot be acquired. A *timeout* argument of ``-1``
536 when *blocking* is ``False``.
568 .. _rlock-objects:
571 -------------
586 Reentrant locks also support the :ref:`context management protocol <with-locks>`.
593 reentrant lock, the same thread may acquire it again without blocking; the
601 .. method:: acquire(blocking=True, timeout=-1)
603 Acquire a lock, blocking or non-blocking.
608 unlocked (not owned by any thread), then grab ownership, set the recursion level
613 When invoked with the *blocking* argument set to ``True``, do the same thing as when
616 When invoked with the *blocking* argument set to ``False``, do not block. If a call
620 When invoked with the floating-point *timeout* argument set to a positive
644 .. _condition-objects:
647 -----------------
654 A condition variable obeys the :ref:`context management protocol <with-locks>`:
664 re-acquires the lock and returns. It is also possible to specify a timeout.
683 producer-consumer situation with unlimited buffer capacity::
699 no longer hold true. This is inherent to multi-threaded programming. The
710 waiting threads. E.g. in a typical producer-consumer situation, adding one
745 occurs. Once awakened or timed out, it re-acquires the lock and returns.
783 held when called and is re-acquired on return. The predicate is evaluated
795 variable; it is a no-op if no threads are waiting.
816 .. _semaphore-objects:
819 -----------------
832 Semaphores also support the :ref:`context management protocol <with-locks>`.
850 .. method:: acquire(blocking=True, timeout=None)
864 When invoked with *blocking* set to ``False``, do not block. If a call
897 .. _semaphore-examples:
925 .. _event-objects:
928 -------------
933 An event object manages an internal flag that can be set to true with the
934 :meth:`~Event.set` method and reset to false with the :meth:`~Event.clear`
940 Class implementing event objects. An event manages a flag that can be set to
941 true with the :meth:`~Event.set` method and reset to false with the
954 .. method:: set()
956 Set the internal flag to true. All threads waiting for it to become true
963 :meth:`wait` will block until :meth:`.set` is called to set the internal
970 :meth:`.set` to set the flag to true, or until the optional timeout occurs.
976 This method returns ``True`` if and only if the internal flag has been set to
985 .. _timer-objects:
988 -------------
991 of time has passed --- a timer. :class:`Timer` is a subclass of :class:`Thread`
1026 ---------------
1070 The return value is an integer in the range 0 to *parties* -- 1, different
1127 .. _with-locks:
1130 -------------------------------------------------------------------------