Module dummy_thread
[hide private]
[frames] | no frames]

Module dummy_thread

Drop-in replacement for the thread module.

Meant to be used as a brain-dead substitute so that threaded code does not need to be rewritten for when the thread module is not present.

Suggested usage is:

   try:
       import thread
   except ImportError:
       import dummy_thread as thread

Author: Brett Cannon

Classes [hide private]
  error
Dummy implementation of thread.error.
  LockType
Class implementing dummy implementation of thread.LockType.
Functions [hide private]
 
start_new_thread(function, args, kwargs={})
Dummy implementation of thread.start_new_thread().
 
exit()
Dummy implementation of thread.exit().
 
get_ident()
Dummy implementation of thread.get_ident().
 
allocate_lock()
Dummy implementation of thread.allocate_lock().
 
stack_size(size=None)
Dummy implementation of thread.stack_size().
 
interrupt_main()
Set _interrupt flag to True to have start_new_thread raise KeyboardInterrupt upon exiting.
Variables [hide private]
  __email__ = 'brett@python.org'
  _interrupt = False
  _main = True

Imports: _traceback, warnings


Function Details [hide private]

start_new_thread(function, args, kwargs={})

 

Dummy implementation of thread.start_new_thread().

Compatibility is maintained by making sure that ``args`` is a tuple and ``kwargs`` is a dictionary. If an exception is raised and it is SystemExit (which can be done by thread.exit()) it is caught and nothing is done; all other exceptions are printed out by using traceback.print_exc().

If the executed function calls interrupt_main the KeyboardInterrupt will be raised when the function returns.

get_ident()

 

Dummy implementation of thread.get_ident().

Since this module should only be used when threadmodule is not available, it is safe to assume that the current process is the only thread. Thus a constant can be safely returned.