示例#1
0
 def __init__(self, func=None, standalone=False, daemon=False):
     """
     Create Softlet from given generator, or from
     the overriden run() method if "func" is not specified.
     If "standalone" is True, Softlet won't be killed
     when parent terminates.
     If "daemon" is True, Softlet is automatically killed
     when no non-daemon Softlets are left.
     """
     WaitObject.__init__(self)
     self.standalone = standalone
     self.switcher = current_switcher()
     self.children = set()
     self.daemon = daemon
     if not standalone:
         self.parent = self.switcher.current_thread
         if self.parent:
             self.parent.children.add(self)
     else:
         self.parent = None
     self.waiting_on = None
     self.start(func)
示例#2
0
 def __init__(self):
     WaitObject.__init__(self)
     self.set_ready(True)