Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
threading._Timer Class Reference
Inheritance diagram for threading._Timer:
Inheritance graph
[legend]
Collaboration diagram for threading._Timer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def cancel
def run
def daemon
def daemon
def name
def name
def __repr__
def start
def join
def ident
def is_alive
def isDaemon
def setDaemon
def getName
def setName

Public Attributes

 interval
 function
 args
 kwargs
 finished
 daemon
 name
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Public Attributes

 isAlive = is_alive

Detailed Description

Call a function after a specified number of seconds:

t = Timer(30.0, f, args=[], kwargs={})
t.start()
t.cancel() # stop the timer's action if it's still waiting

Definition at line 923 of file threading.py.


Constructor & Destructor Documentation

def threading._Timer.__init__ (   self,
  interval,
  function,
  args = [],
  kwargs = {} 
)

Definition at line 931 of file threading.py.

00931 
00932     def __init__(self, interval, function, args=[], kwargs={}):
00933         Thread.__init__(self)
00934         self.interval = interval
00935         self.function = function
00936         self.args = args
00937         self.kwargs = kwargs
00938         self.finished = Event()

Here is the caller graph for this function:


Member Function Documentation

def threading.Thread.__repr__ (   self) [inherited]

Definition at line 659 of file threading.py.

00659 
00660     def __repr__(self):
00661         assert self._initialized, "Thread.__init__() was not called"
00662         status = "initial"
00663         if self._started.is_set():
00664             status = "started"
00665         if self._stopped:
00666             status = "stopped"
00667         if self._daemonic:
00668             status += " daemon"
00669         if self._ident is not None:
00670             status += " %s" % self._ident
00671         return "<%s(%s, %s)>" % (self.__class__.__name__, self._name, status)

def threading._Timer.cancel (   self)
Stop the timer if it hasn't finished yet

Definition at line 939 of file threading.py.

00939 
00940     def cancel(self):
00941         """Stop the timer if it hasn't finished yet"""
00942         self.finished.set()

Here is the caller graph for this function:

def threading.Thread.daemon (   self) [inherited]

Definition at line 894 of file threading.py.

00894 
00895     def daemon(self):
00896         assert self._initialized, "Thread.__init__() not called"
00897         return self._daemonic

def threading.Thread.daemon (   self,
  daemonic 
) [inherited]

Definition at line 899 of file threading.py.

00899 
00900     def daemon(self, daemonic):
00901         if not self._initialized:
00902             raise RuntimeError("Thread.__init__() not called")
00903         if self._started.is_set():
00904             raise RuntimeError("cannot set daemon status of active thread");
00905         self._daemonic = daemonic

def threading.Thread.getName (   self) [inherited]

Definition at line 912 of file threading.py.

00912 
00913     def getName(self):
00914         return self.name

def threading.Thread.ident (   self) [inherited]

Definition at line 883 of file threading.py.

00883 
00884     def ident(self):
00885         assert self._initialized, "Thread.__init__() not called"
00886         return self._ident

def threading.Thread.is_alive (   self) [inherited]

Definition at line 887 of file threading.py.

00887 
00888     def is_alive(self):
00889         assert self._initialized, "Thread.__init__() not called"
00890         return self._started.is_set() and not self._stopped

Here is the caller graph for this function:

def threading.Thread.isDaemon (   self) [inherited]

Definition at line 906 of file threading.py.

00906 
00907     def isDaemon(self):
00908         return self.daemon

def threading.Thread.join (   self,
  timeout = None 
) [inherited]

Reimplemented in threading._DummyThread.

Definition at line 838 of file threading.py.

00838 
00839     def join(self, timeout=None):
00840         if not self._initialized:
00841             raise RuntimeError("Thread.__init__() not called")
00842         if not self._started.is_set():
00843             raise RuntimeError("cannot join thread before it is started")
00844         if self is current_thread():
00845             raise RuntimeError("cannot join current thread")
00846 
00847         if __debug__:
00848             if not self._stopped:
00849                 self._note("%s.join(): waiting until thread stops", self)
00850 
00851         self._block.acquire()
00852         try:
00853             if timeout is None:
00854                 while not self._stopped:
00855                     self._block.wait()
00856                 if __debug__:
00857                     self._note("%s.join(): thread stopped", self)
00858             else:
00859                 deadline = _time() + timeout
00860                 while not self._stopped:
00861                     delay = deadline - _time()
00862                     if delay <= 0:
00863                         if __debug__:
00864                             self._note("%s.join(): timed out", self)
00865                         break
00866                     self._block.wait(delay)
00867                 else:
00868                     if __debug__:
00869                         self._note("%s.join(): thread stopped", self)
00870         finally:
00871             self._block.release()

Here is the call graph for this function:

Here is the caller graph for this function:

def threading.Thread.name (   self) [inherited]

Definition at line 873 of file threading.py.

00873 
00874     def name(self):
00875         assert self._initialized, "Thread.__init__() not called"
00876         return self._name

Here is the caller graph for this function:

def threading.Thread.name (   self,
  name 
) [inherited]

Definition at line 878 of file threading.py.

00878 
00879     def name(self, name):
00880         assert self._initialized, "Thread.__init__() not called"
00881         self._name = str(name)

Here is the caller graph for this function:

def threading._Timer.run (   self)

Reimplemented from threading.Thread.

Definition at line 943 of file threading.py.

00943 
00944     def run(self):
00945         self.finished.wait(self.interval)
00946         if not self.finished.is_set():
00947             self.function(*self.args, **self.kwargs)
00948         self.finished.set()
00949 
00950 # Special thread class to represent the main thread
00951 # This is garbage collected through an exit handler

Here is the caller graph for this function:

def threading.Thread.setDaemon (   self,
  daemonic 
) [inherited]

Definition at line 909 of file threading.py.

00909 
00910     def setDaemon(self, daemonic):
00911         self.daemon = daemonic

def threading.Thread.setName (   self,
  name 
) [inherited]

Definition at line 915 of file threading.py.

00915 
00916     def setName(self, name):
00917         self.name = name
00918 
00919 # The timer class was contributed by Itamar Shtull-Trauring

def threading.Thread.start (   self) [inherited]

Reimplemented in test.test_ftplib.DummyFTPServer, test.test_poplib.DummyPOP3Server, and multiprocessing.dummy.DummyProcess.

Definition at line 672 of file threading.py.

00672 
00673     def start(self):
00674         if not self._initialized:
00675             raise RuntimeError("thread.__init__() not called")
00676 
00677         if self._started.is_set():
00678             raise RuntimeError("threads can only be started once")
00679         if __debug__:
00680             self._note("%s.start(): starting thread", self)
00681         with _active_limbo_lock:
00682             _limbo[self] = self
00683         try:
00684             _start_new_thread(self._bootstrap, ())
00685         except Exception:
00686             with _active_limbo_lock:
00687                 del _limbo[self]
00688             raise
00689         self._started.wait()

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 935 of file threading.py.

Definition at line 937 of file threading.py.

Definition at line 934 of file threading.py.

Definition at line 933 of file threading.py.

threading.Thread.isAlive = is_alive [static, inherited]

Definition at line 891 of file threading.py.

Definition at line 936 of file threading.py.

threading.Thread.name [inherited]

Definition at line 916 of file threading.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.


The documentation for this class was generated from the following file: