def __init__(self, threadpool): RawGreenlet.__init__(self, threadpool._worker) self.thread_ident = get_thread_ident() self._threadpool_wref = wref(threadpool) # Inform the gevent.util.GreenletTree that this should be # considered the root (for printing purposes) and to # ignore the parent attribute. (We can't set parent to None.) self.greenlet_tree_is_root = True self.parent.greenlet_tree_is_ignored = True
def _begin(self): # we're in the new thread (but its root greenlet). Establish invariants and get going # by making this the current greenlet. self.parent = getcurrent() # pylint:disable=attribute-defined-outside-init self._thread_ident = get_thread_ident() # ignore the parent attribute. (We can't set parent to None.) self.parent.greenlet_tree_is_ignored = True try: self.switch() # goto run() except: # pylint:disable=bare-except # run() will attempt to print any exceptions, but that might # not work during shutdown. sys.excepthook and such may be gone, # so things might not get printed at all except for a cryptic # message. This is especially true on Python 2 (doesn't seem to be # an issue on Python 3). pass