• Home
  • Raw
  • Download

Lines Matching full:thread

12 level :mod:`thread` module.
16 :mod:`threading` cannot be used because :mod:`thread` is missing.
29 Starting with Python 2.5, several Thread methods raise :exc:`RuntimeError`
34 In CPython, due to the :term:`Global Interpreter Lock`, only one thread
48 Return the number of :class:`Thread` objects currently alive. The returned
60 thread.
68 Return the current :class:`Thread` object, corresponding to the caller's thread
69 of control. If the caller's thread of control was not created through the
70 :mod:`threading` module, a dummy thread object with limited functionality is
79 Return a list of all :class:`Thread` objects currently alive. The list
80 includes daemonic threads, dummy thread objects created by
81 :func:`current_thread`, and the main thread. It excludes terminated threads
98 A class that represents thread-local data. Thread-local data are data whose
99 values are thread specific. To manage thread-local data, just create an
115 A factory function that returns a new primitive lock object. Once a thread has
117 thread may release it.
125 must be released by the thread that acquired it. Once a thread has acquired a
126 reentrant lock, the same thread may acquire it again without blocking; the
127 thread must release it once for each time it has acquired it.
153 .. class:: Thread
156 A class that represents a thread of control. This class can be safely
159 See :ref:`thread-objects`.
165 A thread that executes a function after a specified interval has passed.
175 The *func* will be passed to :func:`sys.settrace` for each thread, before its
176 :meth:`~Thread.run` method is called.
186 The *func* will be passed to :func:`sys.setprofile` for each thread, before its
187 :meth:`~Thread.run` method is called.
194 Return the thread stack size used when creating new threads. The optional
198 0 is used. If changing the thread stack size is
223 they are separate objects in Python. Python's :class:`Thread` class supports a
224 subset of the behavior of Java's Thread class; currently, there are no
225 priorities, no thread groups, and threads cannot be destroyed, stopped,
226 suspended, resumed, or interrupted. The static methods of Java's Thread class,
234 Thread Objects
237 This class represents an activity that is run in a separate thread of control.
244 Once a thread object is created, its activity must be started by calling the
245 thread's :meth:`start` method. This invokes the :meth:`run` method in a
246 separate thread of control.
248 Once the thread's activity is started, the thread is considered 'alive'. It
251 thread is alive.
253 Other threads can call a thread's :meth:`join` method. This blocks the calling
254 thread until the thread whose :meth:`join` method is called is terminated.
256 A thread has a name. The name can be passed to the constructor, and read or
259 A thread can be flagged as a "daemon thread". The significance of this flag is
261 initial value is inherited from the creating thread. The flag can be set
270 There is a "main thread" object; this corresponds to the initial thread of
271 control in the Python program. It is not a daemon thread.
273 There is the possibility that "dummy thread objects" are created. These are
274 thread objects corresponding to "alien threads", which are threads of control
276 thread objects have limited functionality; they are always considered alive and
281 .. class:: Thread(group=None, target=None, name=None, args=(), kwargs={})
292 *name* is the thread name. By default, a unique name is constructed of the
293 form "Thread-*N*" where *N* is a small decimal number.
301 base class constructor (``Thread.__init__()``) before doing anything else to
302 the thread.
306 Start the thread's activity.
308 It must be called at most once per thread object. It arranges for the
309 object's :meth:`run` method to be invoked in a separate thread of control.
312 on the same thread object.
316 Method representing the thread's activity.
325 Wait until the thread terminates. This blocks the calling thread until the
326 thread whose :meth:`join` method is called terminates -- either normally
333 happened -- if the thread is still alive, the :meth:`join` call timed out.
336 block until the thread terminates.
338 A thread can be :meth:`join`\ ed many times.
341 the current thread as that would cause a deadlock. It is also an error to
342 :meth:`join` a thread before it has been started and attempts to do so
356 Pre-2.6 API for :attr:`~Thread.name`.
360 The 'thread identifier' of this thread or ``None`` if the thread has not
362 :func:`thread.get_ident()` function. Thread identifiers may be recycled
363 when a thread exits and another thread is created. The identifier is
364 available even after the thread has exited.
371 Return whether the thread is alive.
382 A boolean value indicating whether this thread is a daemon thread (True)
385 from the creating thread; the main thread is not a daemon thread and
386 therefore all threads created in the main thread default to :attr:`daemon`
396 Pre-2.6 API for :attr:`~Thread.daemon`.
405 particular thread when locked. In Python, it is currently the lowest level
406 synchronization primitive available, implemented directly by the :mod:`thread`
413 blocks until a call to :meth:`release` in another thread changes it to unlocked,
419 When more than one thread is blocked in :meth:`acquire` waiting for the state to
420 turn to unlocked, only one thread proceeds when a :meth:`release` call resets
458 times by the same thread. Internally, it uses the concepts of "owning thread"
460 locks. In the locked state, some thread owns the lock; in the unlocked state,
461 no thread owns it.
463 To lock the lock, a thread calls its :meth:`acquire` method; this returns once
464 the thread owns the lock. To unlock the lock, a thread calls its
467 pair) resets the lock to unlocked and allows another thread blocked in
475 When invoked without arguments: if this thread already owns the lock, increment
477 thread owns the lock, block until the lock is unlocked. Once the lock is
478 unlocked (not owned by any thread), then grab ownership, set the recursion level
479 to one, and return. If more than one thread is blocked waiting until the lock
494 zero, reset the lock to unlocked (not owned by any thread), and if any other
497 nonzero, the lock remains locked and owned by the calling thread.
499 Only call this method when the calling thread owns the lock. A
518 be called when the calling thread has acquired the lock, otherwise a
523 another thread. Once awakened, it re-acquires the lock and returns. It is also
531 this means that the thread or threads awakened will not return from their
532 :meth:`wait` call immediately, but only when the thread that called
559 needs to wake up one consumer thread.
580 Wait until notified or until a timeout occurs. If the calling thread has not
585 condition variable in another thread, or until the optional timeout
602 By default, wake up one thread waiting on this condition, if any. If the
603 calling thread has not acquired the lock when this method is called, a
614 Note: an awakened thread does not actually return from its :meth:`wait`
623 calling thread has not acquired the lock when this method is called, a
642 waiting until some other thread calls :meth:`release`.
657 on entry, block, waiting until some other thread has called
674 was zero on entry and another thread is waiting for it to become larger
675 than zero again, wake up that thread.
686 main thread would initialize the semaphore::
711 thread signals an event and other threads wait for it.
745 entry, return immediately. Otherwise, block until another thread calls
766 of time has passed --- a timer. :class:`Timer` is a subclass of :class:`Thread`
822 While the import machinery is thread-safe, there are two key restrictions on
823 threaded imports due to inherent limitations in the way that thread-safety is
827 side effect of spawning a new thread and then waiting for that thread in
829 the spawned thread directly or indirectly attempts to import a module.
833 module. Daemon threads and threads created directly with the thread