home *** CD-ROM | disk | FTP | other *** search
/ Freelog 116 / FreelogNo116-JuilletSeptembre2013.iso / GestionFichiers / metamorphose / metamorphose2_0.8.2_setup.exe / metamorphose2.exe / dummy_thread.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2011-01-12  |  3KB  |  107 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. __all__ = [
  5.     'error',
  6.     'start_new_thread',
  7.     'exit',
  8.     'get_ident',
  9.     'allocate_lock',
  10.     'interrupt_main',
  11.     'LockType']
  12. import traceback as _traceback
  13.  
  14. class error(Exception):
  15.     
  16.     def __init__(self, *args):
  17.         self.args = args
  18.  
  19.  
  20.  
  21. def start_new_thread(function, args, kwargs = { }):
  22.     global _main, _interrupt
  23.     if type(args) != type(tuple()):
  24.         raise TypeError('2nd arg must be a tuple')
  25.     type(args) != type(tuple())
  26.     if type(kwargs) != type(dict()):
  27.         raise TypeError('3rd arg must be a dict')
  28.     type(kwargs) != type(dict())
  29.     _main = False
  30.     
  31.     try:
  32.         function(*args, **kwargs)
  33.     except SystemExit:
  34.         pass
  35.     except:
  36.         _traceback.print_exc()
  37.  
  38.     _main = True
  39.     if _interrupt:
  40.         _interrupt = False
  41.         raise KeyboardInterrupt
  42.     _interrupt
  43.  
  44.  
  45. def exit():
  46.     raise SystemExit
  47.  
  48.  
  49. def get_ident():
  50.     return -1
  51.  
  52.  
  53. def allocate_lock():
  54.     return LockType()
  55.  
  56.  
  57. def stack_size(size = None):
  58.     if size is not None:
  59.         raise error('setting thread stack size not supported')
  60.     size is not None
  61.     return 0
  62.  
  63.  
  64. class LockType(object):
  65.     
  66.     def __init__(self):
  67.         self.locked_status = False
  68.  
  69.     
  70.     def acquire(self, waitflag = None):
  71.         if waitflag is None or waitflag:
  72.             self.locked_status = True
  73.             return True
  74.         if not self.locked_status:
  75.             self.locked_status = True
  76.             return True
  77.         return False
  78.  
  79.     __enter__ = acquire
  80.     
  81.     def __exit__(self, typ, val, tb):
  82.         self.release()
  83.  
  84.     
  85.     def release(self):
  86.         if not self.locked_status:
  87.             raise error
  88.         self.locked_status
  89.         self.locked_status = False
  90.         return True
  91.  
  92.     
  93.     def locked(self):
  94.         return self.locked_status
  95.  
  96.  
  97. _interrupt = False
  98. _main = True
  99.  
  100. def interrupt_main():
  101.     global _interrupt
  102.     if _main:
  103.         raise KeyboardInterrupt
  104.     _main
  105.     _interrupt = True
  106.  
  107.