home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_641 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  4.8 KB  |  136 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __all__ = [
  5.     'Process',
  6.     'current_process',
  7.     'active_children',
  8.     'freeze_support',
  9.     'Lock',
  10.     'RLock',
  11.     'Semaphore',
  12.     'BoundedSemaphore',
  13.     'Condition',
  14.     'Event',
  15.     'Queue',
  16.     'Manager',
  17.     'Pipe',
  18.     'Pool',
  19.     'JoinableQueue']
  20. import threading
  21. import sys
  22. import weakref
  23. import array
  24. import itertools
  25. from multiprocessing import TimeoutError, cpu_count
  26. from multiprocessing.dummy.connection import Pipe
  27. from threading import Lock, RLock, Semaphore, BoundedSemaphore
  28. from threading import Event
  29. from Queue import Queue
  30.  
  31. class DummyProcess(threading.Thread):
  32.     
  33.     def __init__(self, group = None, target = None, name = None, args = (), kwargs = { }):
  34.         threading.Thread.__init__(self, group, target, name, args, kwargs)
  35.         self._pid = None
  36.         self._children = weakref.WeakKeyDictionary()
  37.         self._start_called = False
  38.         self._parent = current_process()
  39.  
  40.     
  41.     def start(self):
  42.         self._start_called = True
  43.         self._parent._children[self] = None
  44.         threading.Thread.start(self)
  45.  
  46.     
  47.     def exitcode(self):
  48.         if self._start_called and not self.is_alive():
  49.             return 0
  50.         return None
  51.  
  52.     exitcode = property(exitcode)
  53.  
  54.  
  55. class Condition(threading._Condition):
  56.     notify_all = threading._Condition.notify_all.im_func
  57.  
  58. Process = DummyProcess
  59. current_process = threading.current_thread
  60. current_process()._children = weakref.WeakKeyDictionary()
  61.  
  62. def active_children():
  63.     children = current_process()._children
  64.     for p in list(children):
  65.         if not p.is_alive():
  66.             children.pop(p, None)
  67.             continue
  68.     
  69.     return list(children)
  70.  
  71.  
  72. def freeze_support():
  73.     pass
  74.  
  75.  
  76. class Namespace(object):
  77.     
  78.     def __init__(self, **kwds):
  79.         self.__dict__.update(kwds)
  80.  
  81.     
  82.     def __repr__(self):
  83.         items = self.__dict__.items()
  84.         temp = []
  85.         for name, value in items:
  86.             if not name.startswith('_'):
  87.                 temp.append('%s=%r' % (name, value))
  88.                 continue
  89.         
  90.         temp.sort()
  91.         return 'Namespace(%s)' % str.join(', ', temp)
  92.  
  93.  
  94. dict = dict
  95. list = list
  96.  
  97. def Array(typecode, sequence, lock = True):
  98.     return array.array(typecode, sequence)
  99.  
  100.  
  101. class Value(object):
  102.     
  103.     def __init__(self, typecode, value, lock = True):
  104.         self._typecode = typecode
  105.         self._value = value
  106.  
  107.     
  108.     def _get(self):
  109.         return self._value
  110.  
  111.     
  112.     def _set(self, value):
  113.         self._value = value
  114.  
  115.     value = property(_get, _set)
  116.     
  117.     def __repr__(self):
  118.         return '<%r(%r, %r)>' % (type(self).__name__, self._typecode, self._value)
  119.  
  120.  
  121.  
  122. def Manager():
  123.     return sys.modules[__name__]
  124.  
  125.  
  126. def shutdown():
  127.     pass
  128.  
  129.  
  130. def Pool(processes = None, initializer = None, initargs = ()):
  131.     ThreadPool = ThreadPool
  132.     import multiprocessing.pool
  133.     return ThreadPool(processes, initializer, initargs)
  134.  
  135. JoinableQueue = Queue
  136.