direct.stdpy.threading
from direct.stdpy.threading import BoundedSemaphore, Condition, Event, ExternalThread, Lock, MainThread, RLock, Semaphore, Thread, ThreadBase, Timer, active_count, current_thread, enumerate, main_thread, setprofile, settrace, stack_size
This module reimplements Python’s native threading module using Panda threading constructs. It’s designed as a drop-in replacement for the threading module for code that works with Panda; it is necessary because in some compilation models, Panda’s threading constructs are incompatible with the OS-provided threads used by Python’s thread module.
This module implements the threading module with a thin layer over Panda’s threading constructs. As such, the semantics are close to, but not precisely, the semantics documented for Python’s standard threading module. If you really do require strict adherence to Python’s semantics, see the threading2 module instead.
However, if you don’t need such strict adherence to Python’s original semantics, this module is probably a better choice. It is likely to be slighly faster than the threading2 module (and even slightly faster than Python’s own threading module). It is also better integrated with Panda’s threads, so that Panda’s thread debug mechanisms will be easier to use and understand.
It is permissible to mix-and-match both threading and threading2 within the same application.
Inheritance diagram
- class BoundedSemaphore(value=1)[source]
Bases:
SemaphoreThis class provides a wrapper around Panda’s Semaphore object. The wrapper is designed to emulate Python’s own threading.BoundedSemaphore object.
- class Condition(lock=None)[source]
Bases:
ConditionVarFullThis class provides a wrapper around Panda’s ConditionVarFull object. The wrapper is designed to emulate Python’s own threading.Condition object.
- class Event[source]
Bases:
objectThis class is designed to emulate Python’s own threading.Event object.
- class ExternalThread(extThread, threadId)[source]
Bases:
ThreadBaseReturned for a Thread object that wasn’t created by this interface.
- class Lock(name='PythonLock')[source]
Bases:
MutexThis class provides a wrapper around Panda’s Mutex object. The wrapper is designed to emulate Python’s own threading.Lock object.
- class MainThread(extThread, threadId)[source]
Bases:
ExternalThreadReturned for the MainThread object.
- class RLock(name='PythonRLock')[source]
Bases:
ReMutexThis class provides a wrapper around Panda’s ReMutex object. The wrapper is designed to emulate Python’s own threading.RLock object.
- class Semaphore(value=1)[source]
Bases:
SemaphoreThis class provides a wrapper around Panda’s Semaphore object. The wrapper is designed to emulate Python’s own threading.Semaphore object.
- class Thread(group=None, target=None, name=None, args=(), kwargs={}, daemon=None)[source]
Bases:
ThreadBaseThis class provides a wrapper around Panda’s PythonThread object. The wrapper is designed to emulate Python’s own threading.Thread object.
- class ThreadBase[source]
Bases:
objectA base class for both Thread and ExternalThread in this module.
- considerYield()
C++ Interface: consider_yield()
- /**
Possibly suspends the current thread for the rest of the current epoch, if
it has run for enough this epoch. This is especially important for the
simple thread implementation, which relies on cooperative yields like this.
*/
